Change layout (ProjectScaffold) and add documentation. Fix ridders.
This commit is contained in:
Родитель
b04462772c
Коммит
5b00172cb1
|
@ -1,63 +1,26 @@
|
|||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
# Auto detect text files
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp text=auto eol=lf
|
||||
*.vb diff=csharp text=auto eol=lf
|
||||
*.fs diff=csharp text=auto eol=lf
|
||||
*.fsi diff=csharp text=auto eol=lf
|
||||
*.fsx diff=csharp text=auto eol=lf
|
||||
*.sln text eol=crlf merge=union
|
||||
*.csproj merge=union
|
||||
*.vbproj merge=union
|
||||
*.fsproj merge=union
|
||||
*.dbproj merge=union
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
**/*.nupkg
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userprefs
|
||||
*.sln.docstates
|
||||
.vs/
|
||||
|
||||
# Xamarin Studio / monodevelop user-specific
|
||||
*.userprefs
|
||||
*.dll.mdb
|
||||
*.exe.mdb
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
#build/ #WebSharper
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
!packages/*/build/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
@ -62,6 +61,9 @@ ipch/
|
|||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Other Visual Studio data
|
||||
.vs/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
|
@ -98,8 +100,8 @@ publish/
|
|||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages/
|
||||
# Enable nuget.exe in the .nuget folder (though normally executables are not tracked)
|
||||
!.nuget/NuGet.exe
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
|
@ -156,3 +158,32 @@ $RECYCLE.BIN/
|
|||
|
||||
# Mac desktop service store files
|
||||
.DS_Store
|
||||
|
||||
# ===================================================
|
||||
# Exclude F# project specific directories and files
|
||||
# ===================================================
|
||||
|
||||
# NuGet Packages Directory
|
||||
packages/
|
||||
|
||||
# Generated documentation folder
|
||||
docs/output/
|
||||
|
||||
# Temp folder used for publishing docs
|
||||
temp/
|
||||
|
||||
# Test results produced by build
|
||||
TestResults.xml
|
||||
|
||||
# Nuget outputs
|
||||
nuget/*.nupkg
|
||||
release.cmd
|
||||
release.sh
|
||||
localpackages/
|
||||
paket-files
|
||||
*.orig
|
||||
.paket/paket.exe
|
||||
docs/content/license.md
|
||||
docs/content/release-notes.md
|
||||
.fake
|
||||
docs/tools/FSharp.Formatting.svclog
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<!-- Enable the restore command to run before builds -->
|
||||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
|
||||
<!-- Download Paket.exe if it does not already exist -->
|
||||
<DownloadPaket Condition=" '$(DownloadPaket)' == '' ">true</DownloadPaket>
|
||||
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
|
||||
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Paket command -->
|
||||
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
|
||||
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
|
||||
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
|
||||
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
|
||||
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
|
||||
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(PaketBootStrapperExePath)</PaketBootStrapperCommand>
|
||||
<!-- Commands -->
|
||||
<RestoreCommand>$(PaketCommand) restore</RestoreCommand>
|
||||
<DownloadPaketCommand>$(PaketBootStrapperCommand)</DownloadPaketCommand>
|
||||
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
<Target Name="CheckPrerequisites">
|
||||
<!-- Raise an error if we're unable to locate paket.exe -->
|
||||
<Error Condition="'$(DownloadPaket)' != 'true' AND !Exists('$(PaketExePath)')" Text="Unable to locate '$(PaketExePath)'" />
|
||||
<MsBuild Targets="DownloadPaket" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadPaket=$(DownloadPaket)" />
|
||||
</Target>
|
||||
<Target Name="DownloadPaket">
|
||||
<Exec Command="$(DownloadPaketCommand)" Condition=" '$(DownloadPaket)' == 'true' AND !Exists('$(PaketExePath)')" />
|
||||
</Target>
|
||||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(RestoreCommand)" WorkingDirectory="$(PaketRootPath)" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,9 @@
|
|||
language: csharp
|
||||
|
||||
sudo: false # use the new container-based Travis infrastructure
|
||||
|
||||
before_install:
|
||||
- chmod +x build.sh
|
||||
|
||||
script:
|
||||
- ./build.sh All
|
|
@ -1,109 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>715a3795-0206-4a37-8fee-40eca36a5dd2</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Angara.Statistics.Tests</RootNamespace>
|
||||
<AssemblyName>Angara.Statistics.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Name>Angara.Statistics.Tests</Name>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<Tailcalls>false</Tailcalls>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\Angara.Statistics.Tests.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Tailcalls>true</Tailcalls>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Angara.Statistics.Tests.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '11.0'">
|
||||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
|
||||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
|
||||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<Import Project="$(FSharpTargetsPath)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<Compile Include="Tests.fs" />
|
||||
<Compile Include="FilzbachTests.fs" />
|
||||
<Content Include="packages.config" />
|
||||
<Content Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<Reference Include="FsUnit.NUnit">
|
||||
<HintPath>..\packages\FsUnit.1.4.1.0\lib\net45\FsUnit.NUnit.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="NHamcrest">
|
||||
<HintPath>..\packages\FsUnit.1.4.1.0\lib\net45\NHamcrest.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core">
|
||||
<HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.core.interfaces">
|
||||
<HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.util">
|
||||
<HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NUnit.VisualStudio.TestAdapter">
|
||||
<HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Angara.Statistics\Angara.Statistics.fsproj">
|
||||
<Name>Angara.Statistics</Name>
|
||||
<Project>{7dc6271f-642e-4431-bb7c-24f49a36413c}</Project>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.4.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.6.4.14350" newVersion="2.6.4.14350" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -1,41 +0,0 @@
|
|||
namespace Angara.Statistics.Tests.AssemblyInfo
|
||||
|
||||
open System.Reflection
|
||||
open System.Runtime.CompilerServices
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[<assembly: AssemblyTitle("Angara.Statistics.Tests")>]
|
||||
[<assembly: AssemblyDescription("")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("")>]
|
||||
[<assembly: AssemblyProduct("Angara.Statistics.Tests")>]
|
||||
[<assembly: AssemblyCopyright("Copyright © 2015")>]
|
||||
[<assembly: AssemblyTrademark("")>]
|
||||
[<assembly: AssemblyCulture("")>]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[<assembly: ComVisible(false)>]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[<assembly: Guid("715a3795-0206-4a37-8fee-40eca36a5dd2")>]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [<assembly: AssemblyVersion("1.0.*")>]
|
||||
[<assembly: AssemblyVersion("1.0.0.0")>]
|
||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
||||
|
||||
do
|
||||
()
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FSharp.Core" version="3.1.2.5" targetFramework="net461" />
|
||||
<package id="FsUnit" version="1.4.1.0" targetFramework="net45" />
|
||||
<package id="NUnit" version="2.6.4" targetFramework="net452" />
|
||||
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net452" />
|
||||
</packages>
|
|
@ -1,34 +1,45 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Angara.Statistics", "Angara.Statistics\Angara.Statistics.fsproj", "{7DC6271F-642E-4431-BB7C-24F49A36413C}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Angara.Statistics.Tests", "Angara.Statistics.Tests\Angara.Statistics.Tests.fsproj", "{715A3795-0206-4A37-8FEE-40ECA36A5DD2}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{09EAF7B5-870E-4D5B-8FC2-296DA4380C21}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{63297B98-5CED-492C-A5B7-A5B4F73CF142}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
LICENSE = LICENSE
|
||||
README.md = README.md
|
||||
paket.dependencies = paket.dependencies
|
||||
paket.lock = paket.lock
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Angara.Statistics", "src\Angara.Statistics\Angara.Statistics.fsproj", "{5161430D-44B4-441C-BE95-89C02F215D38}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{BF60BC93-E09B-4E5F-9D85-95A519479D54}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build.fsx = build.fsx
|
||||
README.md = README.md
|
||||
RELEASE_NOTES.md = RELEASE_NOTES.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ED8079DD-2B06-4030-9F0F-DC548F98E1C4}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Angara.Statistics.Tests", "tests\Angara.Statistics.Tests\Angara.Statistics.Tests.fsproj", "{D5620A55-AA34-4DE7-A970-B2168A06D28D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7DC6271F-642E-4431-BB7C-24F49A36413C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7DC6271F-642E-4431-BB7C-24F49A36413C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7DC6271F-642E-4431-BB7C-24F49A36413C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7DC6271F-642E-4431-BB7C-24F49A36413C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{715A3795-0206-4A37-8FEE-40ECA36A5DD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{715A3795-0206-4A37-8FEE-40ECA36A5DD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{715A3795-0206-4A37-8FEE-40ECA36A5DD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{715A3795-0206-4A37-8FEE-40ECA36A5DD2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5161430D-44B4-441C-BE95-89C02F215D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5161430D-44B4-441C-BE95-89C02F215D38}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5161430D-44B4-441C-BE95-89C02F215D38}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5161430D-44B4-441C-BE95-89C02F215D38}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D5620A55-AA34-4DE7-A970-B2168A06D28D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D5620A55-AA34-4DE7-A970-B2168A06D28D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D5620A55-AA34-4DE7-A970-B2168A06D28D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D5620A55-AA34-4DE7-A970-B2168A06D28D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{D5620A55-AA34-4DE7-A970-B2168A06D28D} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
namespace Angara.AssemblyInfo
|
||||
|
||||
open System.Reflection
|
||||
open System.Runtime.CompilerServices
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
module internal Const =
|
||||
[<Literal>]
|
||||
let Version = "0.1.2" // Assembly semantic version
|
||||
|
||||
[<assembly: AssemblyTitle("Angara.Statistics")>]
|
||||
[<assembly: AssemblyDescription("A random number generator, probability distributions, a gaussian kernel density estimator and an MCMC sampler.")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("Microsoft Research")>]
|
||||
[<assembly: AssemblyProduct("Angara")>]
|
||||
[<assembly: AssemblyCopyright("Copyright © Microsoft Research 2016")>]
|
||||
[<assembly: AssemblyTrademark("")>]
|
||||
[<assembly: AssemblyCulture("")>]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[<assembly: ComVisible(false)>]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[<assembly: Guid("7dc6271f-642e-4431-bb7c-24f49a36413c")>]
|
||||
|
||||
|
||||
[<assembly: AssemblyVersion(Const.Version + ".0")>]
|
||||
[<assembly: AssemblyFileVersion(Const.Version + ".0")>]
|
||||
|
||||
do
|
||||
()
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,6 +0,0 @@
|
|||
// Warning: generated file; your changes could be lost when a new file is generated.
|
||||
#I __SOURCE_DIRECTORY__
|
||||
#load "load-references-debug.fsx"
|
||||
#load "../AssemblyInfo.fs"
|
||||
"../Statistics.fs"
|
||||
"../Filzbach.fs"
|
|
@ -1,6 +0,0 @@
|
|||
// Warning: generated file; your changes could be lost when a new file is generated.
|
||||
#I __SOURCE_DIRECTORY__
|
||||
#load "load-references-release.fsx"
|
||||
#load "../AssemblyInfo.fs"
|
||||
"../Statistics.fs"
|
||||
"../Filzbach.fs"
|
|
@ -1,5 +0,0 @@
|
|||
// Warning: generated file; your changes could be lost when a new file is generated.
|
||||
#I __SOURCE_DIRECTORY__
|
||||
#r "System.Core.dll"
|
||||
#r "System.dll"
|
||||
#r "System.Numerics.dll"
|
|
@ -1,5 +0,0 @@
|
|||
// Warning: generated file; your changes could be lost when a new file is generated.
|
||||
#I __SOURCE_DIRECTORY__
|
||||
#r "System.Core.dll"
|
||||
#r "System.dll"
|
||||
#r "System.Numerics.dll"
|
27
README.md
27
README.md
|
@ -1,2 +1,27 @@
|
|||
[![Issue Stats](http://issuestats.com/github/microsoft/Angara.Statistics/badge/issue)](http://issuestats.com/github/microsoft/Angara.Statistics)
|
||||
[![Issue Stats](http://issuestats.com/github/microsoft/Angara.Statistics/badge/pr)](http://issuestats.com/github/microsoft/Angara.Statistics)
|
||||
|
||||
# Angara.Statistics
|
||||
F# statistics library
|
||||
|
||||
Angara.Statistics
|
||||
======================
|
||||
|
||||
A collection of essential algorithms for Bayesian data constrained modelling.
|
||||
Includes Mersenne twister random number generator, common probability distributions,
|
||||
sampling statistics and quantiles, a kernel density estimator and
|
||||
a resumable Metropolis-Hastings MCMC sampler.
|
||||
|
||||
Documentation: http://predictionmachines.github.io/Angara.Statistics
|
||||
|
||||
|
||||
## Build Status
|
||||
|
||||
Mono | .NET
|
||||
---- | ----
|
||||
[![Mono CI Build Status](https://img.shields.io/travis/microsoft/Angara.Statistics/master.svg)](https://travis-ci.org/microsoft/Angara.Statistics) | [![.NET Build Status](https://img.shields.io/appveyor/ci/vassilyl/angara-statistics/master.svg)](https://ci.appveyor.com/project/vassilyl/angara-statistics)
|
||||
|
||||
## Maintainer(s)
|
||||
|
||||
- [@vassilyl](https://github.com/vassilyl)
|
||||
- [@msdvoits](https://github.com/msdvoits)
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
### 0.1.3 - 2016-04-12
|
||||
|
||||
* Change layout of the repository to match [ProjectScaffold](http://fsprojects.github.io/ProjectScaffold/) recommendation.
|
||||
* Fix bisection algorithm of `ridders`.
|
||||
* Add documentation
|
||||
* Switch back to .NET Framework 4.5.2
|
||||
|
||||
### 0.1.2 - 2016-03-11
|
||||
|
||||
* `prior` field of `ParameterDefinition` structure is a function instead of a Distribution.
|
||||
* Redesign of `Parameters.Add` overloads.
|
||||
* Switch to .NET Framework 4.6.1
|
||||
|
||||
### 0.1.1 - 2016-02-17
|
||||
|
||||
Initial NuGet release.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
init:
|
||||
- git config --global core.autocrlf input
|
||||
build_script:
|
||||
- cmd: build.cmd
|
||||
test: off
|
||||
version: 0.0.1.{build}
|
||||
artifacts:
|
||||
- path: bin
|
||||
name: bin
|
|
@ -0,0 +1,18 @@
|
|||
@echo off
|
||||
cls
|
||||
|
||||
.paket\paket.bootstrapper.exe
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
.paket\paket.exe restore
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
IF NOT EXIST build.fsx (
|
||||
.paket\paket.exe update
|
||||
packages\build\FAKE\tools\FAKE.exe init.fsx
|
||||
)
|
||||
packages\build\FAKE\tools\FAKE.exe build.fsx %*
|
|
@ -0,0 +1,410 @@
|
|||
// --------------------------------------------------------------------------------------
|
||||
// FAKE build script
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
#r @"packages/build/FAKE/tools/FakeLib.dll"
|
||||
open Fake
|
||||
open Fake.Git
|
||||
open Fake.AssemblyInfoFile
|
||||
open Fake.ReleaseNotesHelper
|
||||
open Fake.UserInputHelper
|
||||
open System
|
||||
open System.IO
|
||||
#if MONO
|
||||
#else
|
||||
#load "packages/build/SourceLink.Fake/tools/Fake.fsx"
|
||||
open SourceLink
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// START TODO: Provide project-specific details below
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// Information about the project are used
|
||||
// - for version and project name in generated AssemblyInfo file
|
||||
// - by the generated NuGet package
|
||||
// - to run tests and to publish documentation on GitHub gh-pages
|
||||
// - for documentation, you also need to edit info in "docs/tools/generate.fsx"
|
||||
|
||||
// The name of the project
|
||||
// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
|
||||
let project = "Angara.Statistics"
|
||||
|
||||
// Short summary of the project
|
||||
// (used as description in AssemblyInfo and as a short summary for NuGet package)
|
||||
let summary = "A collection of statistics algorithms from Mersenne twister generator to MCMC sampling."
|
||||
|
||||
// Longer description of the project
|
||||
// (used as a description for NuGet package; line breaks are automatically cleaned up)
|
||||
let description = "Includes Mersenne twister random number generator, common probability distributions, statistics and quantiles, kernel density estimator, Metropolis-Hastings MCMC sampler."
|
||||
|
||||
// List of author names (for NuGet package)
|
||||
let authors = [ "Vassily Lyutsarev" ]
|
||||
|
||||
// Tags for your project (for NuGet package)
|
||||
let tags = "statistics probability fsharp"
|
||||
|
||||
// File system information
|
||||
let solutionFile = "Angara.Statistics.sln"
|
||||
|
||||
// Pattern specifying assemblies to be tested using NUnit
|
||||
let testAssemblies = "tests/**/bin/Release/*Tests*.dll"
|
||||
|
||||
// Git configuration (used for publishing documentation in gh-pages branch)
|
||||
// The profile where the project is posted
|
||||
let gitOwner = "microsoft"
|
||||
let gitHome = "https://github.com/" + gitOwner
|
||||
|
||||
// The name of the project on GitHub
|
||||
let gitName = "Angara.Statistics"
|
||||
|
||||
// The url for the raw files hosted
|
||||
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/microsoft"
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// END TODO: The rest of the file includes standard build steps
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// Read additional information from the release notes document
|
||||
let release = LoadReleaseNotes "RELEASE_NOTES.md"
|
||||
|
||||
// Helper active pattern for project types
|
||||
let (|Fsproj|Csproj|Vbproj|Shproj|) (projFileName:string) =
|
||||
match projFileName with
|
||||
| f when f.EndsWith("fsproj") -> Fsproj
|
||||
| f when f.EndsWith("csproj") -> Csproj
|
||||
| f when f.EndsWith("vbproj") -> Vbproj
|
||||
| f when f.EndsWith("shproj") -> Shproj
|
||||
| _ -> failwith (sprintf "Project file %s not supported. Unknown project type." projFileName)
|
||||
|
||||
// Generate assembly info files with the right version & up-to-date information
|
||||
Target "AssemblyInfo" (fun _ ->
|
||||
let getAssemblyInfoAttributes projectName =
|
||||
[ Attribute.Title (projectName)
|
||||
Attribute.Product project
|
||||
Attribute.Description summary
|
||||
Attribute.Version release.AssemblyVersion
|
||||
Attribute.FileVersion release.AssemblyVersion ]
|
||||
|
||||
let getProjectDetails projectPath =
|
||||
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
|
||||
( projectPath,
|
||||
projectName,
|
||||
System.IO.Path.GetDirectoryName(projectPath),
|
||||
(getAssemblyInfoAttributes projectName)
|
||||
)
|
||||
|
||||
!! "src/**/*.??proj"
|
||||
|> Seq.map getProjectDetails
|
||||
|> Seq.iter (fun (projFileName, projectName, folderName, attributes) ->
|
||||
match projFileName with
|
||||
| Fsproj -> CreateFSharpAssemblyInfo (folderName </> "AssemblyInfo.fs") attributes
|
||||
| Csproj -> CreateCSharpAssemblyInfo ((folderName </> "Properties") </> "AssemblyInfo.cs") attributes
|
||||
| Vbproj -> CreateVisualBasicAssemblyInfo ((folderName </> "My Project") </> "AssemblyInfo.vb") attributes
|
||||
| Shproj -> ()
|
||||
)
|
||||
)
|
||||
|
||||
// Copies binaries from default VS location to expected bin folder
|
||||
// But keeps a subdirectory structure for each project in the
|
||||
// src folder to support multiple project outputs
|
||||
Target "CopyBinaries" (fun _ ->
|
||||
!! "src/**/*.??proj"
|
||||
-- "src/**/*.shproj"
|
||||
|> Seq.map (fun f -> ((System.IO.Path.GetDirectoryName f) </> "bin/Release", "bin" </> (System.IO.Path.GetFileNameWithoutExtension f)))
|
||||
|> Seq.iter (fun (fromDir, toDir) -> CopyDir toDir fromDir (fun _ -> true))
|
||||
)
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Clean build results
|
||||
|
||||
Target "Clean" (fun _ ->
|
||||
CleanDirs ["bin"; "temp"]
|
||||
)
|
||||
|
||||
Target "CleanDocs" (fun _ ->
|
||||
CleanDirs ["docs/output"]
|
||||
)
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Build library & test project
|
||||
|
||||
Target "Build" (fun _ ->
|
||||
!! solutionFile
|
||||
#if MONO
|
||||
|> MSBuildReleaseExt "" [ ("DefineConstants","MONO") ] "Rebuild"
|
||||
#else
|
||||
|> MSBuildRelease "" "Rebuild"
|
||||
#endif
|
||||
|> ignore
|
||||
)
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Run the unit tests using test runner
|
||||
|
||||
Target "RunTests" (fun _ ->
|
||||
!! testAssemblies
|
||||
|> NUnit (fun p ->
|
||||
{ p with
|
||||
DisableShadowCopy = true
|
||||
TimeOut = TimeSpan.FromMinutes 20.
|
||||
OutputFile = "TestResults.xml" })
|
||||
)
|
||||
|
||||
#if MONO
|
||||
#else
|
||||
// --------------------------------------------------------------------------------------
|
||||
// SourceLink allows Source Indexing on the PDB generated by the compiler, this allows
|
||||
// the ability to step through the source code of external libraries http://ctaggart.github.io/SourceLink/
|
||||
|
||||
Target "SourceLink" (fun _ ->
|
||||
let baseUrl = sprintf "%s/%s/{0}/%%var2%%" gitRaw project
|
||||
!! "src/**/*.??proj"
|
||||
-- "src/**/*.shproj"
|
||||
|> Seq.iter (fun projFile ->
|
||||
let proj = VsProj.LoadRelease projFile
|
||||
SourceLink.Index proj.CompilesNotLinked proj.OutputFilePdb __SOURCE_DIRECTORY__ baseUrl
|
||||
)
|
||||
)
|
||||
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Build a NuGet package
|
||||
|
||||
Target "NuGet" (fun _ ->
|
||||
Paket.Pack(fun p ->
|
||||
{ p with
|
||||
OutputPath = "bin"
|
||||
Version = release.NugetVersion
|
||||
ReleaseNotes = toLines release.Notes})
|
||||
)
|
||||
|
||||
Target "PublishNuget" (fun _ ->
|
||||
Paket.Push(fun p ->
|
||||
{ p with
|
||||
WorkingDir = "bin" })
|
||||
)
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Generate the documentation
|
||||
|
||||
|
||||
let fakePath = "packages" </> "build" </> "FAKE" </> "tools" </> "FAKE.exe"
|
||||
let fakeStartInfo script workingDirectory args fsiargs environmentVars =
|
||||
(fun (info: System.Diagnostics.ProcessStartInfo) ->
|
||||
info.FileName <- System.IO.Path.GetFullPath fakePath
|
||||
info.Arguments <- sprintf "%s --fsiargs -d:FAKE %s \"%s\"" args fsiargs script
|
||||
info.WorkingDirectory <- workingDirectory
|
||||
let setVar k v =
|
||||
info.EnvironmentVariables.[k] <- v
|
||||
for (k, v) in environmentVars do
|
||||
setVar k v
|
||||
setVar "MSBuild" msBuildExe
|
||||
setVar "GIT" Git.CommandHelper.gitPath
|
||||
setVar "FSI" fsiPath)
|
||||
|
||||
/// Run the given buildscript with FAKE.exe
|
||||
let executeFAKEWithOutput workingDirectory script fsiargs envArgs =
|
||||
let exitCode =
|
||||
ExecProcessWithLambdas
|
||||
(fakeStartInfo script workingDirectory "" fsiargs envArgs)
|
||||
TimeSpan.MaxValue false ignore ignore
|
||||
System.Threading.Thread.Sleep 1000
|
||||
exitCode
|
||||
|
||||
// Documentation
|
||||
let buildDocumentationTarget fsiargs target =
|
||||
trace (sprintf "Building documentation (%s), this could take some time, please wait..." target)
|
||||
let exit = executeFAKEWithOutput "docs/tools" "generate.fsx" fsiargs ["target", target]
|
||||
if exit <> 0 then
|
||||
failwith "generating reference documentation failed"
|
||||
()
|
||||
|
||||
Target "GenerateReferenceDocs" (fun _ ->
|
||||
buildDocumentationTarget "-d:RELEASE -d:REFERENCE" "Default"
|
||||
)
|
||||
|
||||
let generateHelp' fail debug =
|
||||
let args =
|
||||
if debug then "--define:HELP"
|
||||
else "--define:RELEASE --define:HELP"
|
||||
try
|
||||
buildDocumentationTarget args "Default"
|
||||
traceImportant "Help generated"
|
||||
with
|
||||
| e when not fail ->
|
||||
traceImportant "generating help documentation failed"
|
||||
|
||||
let generateHelp fail =
|
||||
generateHelp' fail false
|
||||
|
||||
Target "GenerateHelp" (fun _ ->
|
||||
DeleteFile "docs/content/release-notes.md"
|
||||
CopyFile "docs/content/" "RELEASE_NOTES.md"
|
||||
Rename "docs/content/release-notes.md" "docs/content/RELEASE_NOTES.md"
|
||||
|
||||
DeleteFile "docs/content/license.md"
|
||||
CopyFile "docs/content/" "LICENSE.txt"
|
||||
Rename "docs/content/license.md" "docs/content/LICENSE.txt"
|
||||
|
||||
generateHelp true
|
||||
)
|
||||
|
||||
Target "GenerateHelpDebug" (fun _ ->
|
||||
DeleteFile "docs/content/release-notes.md"
|
||||
CopyFile "docs/content/" "RELEASE_NOTES.md"
|
||||
Rename "docs/content/release-notes.md" "docs/content/RELEASE_NOTES.md"
|
||||
|
||||
DeleteFile "docs/content/license.md"
|
||||
CopyFile "docs/content/" "LICENSE.txt"
|
||||
Rename "docs/content/license.md" "docs/content/LICENSE.txt"
|
||||
|
||||
generateHelp' true true
|
||||
)
|
||||
|
||||
Target "KeepRunning" (fun _ ->
|
||||
use watcher = !! "docs/content/**/*.*" |> WatchChanges (fun changes ->
|
||||
generateHelp' true true
|
||||
)
|
||||
|
||||
traceImportant "Waiting for help edits. Press any key to stop."
|
||||
|
||||
System.Console.ReadKey() |> ignore
|
||||
|
||||
watcher.Dispose()
|
||||
)
|
||||
|
||||
Target "GenerateDocs" DoNothing
|
||||
|
||||
let createIndexFsx lang =
|
||||
let content = """(*** hide ***)
|
||||
// This block of code is omitted in the generated HTML documentation. Use
|
||||
// it to define helpers that you do not want to show in the documentation.
|
||||
#I "../../../bin"
|
||||
|
||||
(**
|
||||
F# Project Scaffold ({0})
|
||||
=========================
|
||||
*)
|
||||
"""
|
||||
let targetDir = "docs/content" </> lang
|
||||
let targetFile = targetDir </> "index.fsx"
|
||||
ensureDirectory targetDir
|
||||
System.IO.File.WriteAllText(targetFile, System.String.Format(content, lang))
|
||||
|
||||
Target "AddLangDocs" (fun _ ->
|
||||
let args = System.Environment.GetCommandLineArgs()
|
||||
if args.Length < 4 then
|
||||
failwith "Language not specified."
|
||||
|
||||
args.[3..]
|
||||
|> Seq.iter (fun lang ->
|
||||
if lang.Length <> 2 && lang.Length <> 3 then
|
||||
failwithf "Language must be 2 or 3 characters (ex. 'de', 'fr', 'ja', 'gsw', etc.): %s" lang
|
||||
|
||||
let templateFileName = "template.cshtml"
|
||||
let templateDir = "docs/tools/templates"
|
||||
let langTemplateDir = templateDir </> lang
|
||||
let langTemplateFileName = langTemplateDir </> templateFileName
|
||||
|
||||
if System.IO.File.Exists(langTemplateFileName) then
|
||||
failwithf "Documents for specified language '%s' have already been added." lang
|
||||
|
||||
ensureDirectory langTemplateDir
|
||||
Copy langTemplateDir [ templateDir </> templateFileName ]
|
||||
|
||||
createIndexFsx lang)
|
||||
)
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Release Scripts
|
||||
|
||||
Target "ReleaseDocs" (fun _ ->
|
||||
let tempDocsDir = "temp/gh-pages"
|
||||
CleanDir tempDocsDir
|
||||
Repository.cloneSingleBranch "" (gitHome + "/" + gitName + ".git") "gh-pages" tempDocsDir
|
||||
|
||||
CopyRecursive "docs/output" tempDocsDir true |> tracefn "%A"
|
||||
StageAll tempDocsDir
|
||||
Git.Commit.Commit tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion)
|
||||
Branches.push tempDocsDir
|
||||
)
|
||||
|
||||
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
|
||||
open Octokit
|
||||
|
||||
Target "Release" (fun _ ->
|
||||
let user =
|
||||
match getBuildParam "github-user" with
|
||||
| s when not (String.IsNullOrWhiteSpace s) -> s
|
||||
| _ -> getUserInput "Username: "
|
||||
let pw =
|
||||
match getBuildParam "github-pw" with
|
||||
| s when not (String.IsNullOrWhiteSpace s) -> s
|
||||
| _ -> getUserPassword "Password: "
|
||||
let remote =
|
||||
Git.CommandHelper.getGitResult "" "remote -v"
|
||||
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
|
||||
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
|
||||
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]
|
||||
|
||||
StageAll ""
|
||||
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
|
||||
Branches.pushBranch "" remote (Information.getBranchName "")
|
||||
|
||||
Branches.tag "" release.NugetVersion
|
||||
Branches.pushTag "" remote release.NugetVersion
|
||||
|
||||
// release on github
|
||||
createClient user pw
|
||||
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|
||||
// TODO: |> uploadFile "PATH_TO_FILE"
|
||||
|> releaseDraft
|
||||
|> Async.RunSynchronously
|
||||
)
|
||||
|
||||
Target "BuildPackage" DoNothing
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Run all targets by default. Invoke 'build <Target>' to override
|
||||
|
||||
Target "All" DoNothing
|
||||
|
||||
"Clean"
|
||||
==> "AssemblyInfo"
|
||||
==> "Build"
|
||||
==> "CopyBinaries"
|
||||
==> "RunTests"
|
||||
=?> ("GenerateDocs", TestDir "docs")
|
||||
==> "All"
|
||||
=?> ("ReleaseDocs",isLocalBuild)
|
||||
|
||||
"All"
|
||||
#if MONO
|
||||
#else
|
||||
=?> ("SourceLink", Pdbstr.tryFind().IsSome )
|
||||
#endif
|
||||
==> "NuGet"
|
||||
==> "BuildPackage"
|
||||
|
||||
"CleanDocs"
|
||||
==> "GenerateHelp"
|
||||
==> "GenerateReferenceDocs"
|
||||
==> "GenerateDocs"
|
||||
|
||||
"CleanDocs"
|
||||
==> "GenerateHelpDebug"
|
||||
|
||||
"GenerateHelpDebug"
|
||||
==> "KeepRunning"
|
||||
|
||||
"ReleaseDocs"
|
||||
==> "Release"
|
||||
|
||||
"BuildPackage"
|
||||
==> "PublishNuget"
|
||||
==> "Release"
|
||||
|
||||
RunTargetOrDefault "All"
|
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
cd `dirname $0`
|
||||
|
||||
PAKET_BOOTSTRAPPER_EXE=.paket/paket.bootstrapper.exe
|
||||
PAKET_EXE=.paket/paket.exe
|
||||
FAKE_EXE=packages/build/FAKE/tools/FAKE.exe
|
||||
|
||||
FSIARGS=""
|
||||
OS=${OS:-"unknown"}
|
||||
if [[ "$OS" != "Windows_NT" ]]
|
||||
then
|
||||
FSIARGS="--fsiargs -d:MONO"
|
||||
fi
|
||||
|
||||
function run() {
|
||||
if [[ "$OS" != "Windows_NT" ]]
|
||||
then
|
||||
mono "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function yesno() {
|
||||
# NOTE: Defaults to NO
|
||||
read -p "$1 [y/N] " ynresult
|
||||
case "$ynresult" in
|
||||
[yY]*) true ;;
|
||||
*) false ;;
|
||||
esac
|
||||
}
|
||||
|
||||
set +e
|
||||
run $PAKET_BOOTSTRAPPER_EXE
|
||||
bootstrapper_exitcode=$?
|
||||
set -e
|
||||
|
||||
if [[ "$OS" != "Windows_NT" ]] &&
|
||||
[ $bootstrapper_exitcode -ne 0 ] &&
|
||||
[ $(certmgr -list -c Trust | grep X.509 | wc -l) -le 1 ] &&
|
||||
[ $(certmgr -list -c -m Trust | grep X.509 | wc -l) -le 1 ]
|
||||
then
|
||||
echo "Your Mono installation has no trusted SSL root certificates set up."
|
||||
echo "This may result in the Paket bootstrapper failing to download Paket"
|
||||
echo "because Github's SSL certificate can't be verified. One way to fix"
|
||||
echo "this issue would be to download the list of SSL root certificates"
|
||||
echo "from the Mozilla project by running the following command:"
|
||||
echo ""
|
||||
echo " mozroots --import --sync"
|
||||
echo ""
|
||||
echo "This will import over 100 SSL root certificates into your Mono"
|
||||
echo "certificate repository."
|
||||
echo ""
|
||||
if yesno "Run 'mozroots --import --sync' now?"
|
||||
then
|
||||
mozroots --import --sync
|
||||
else
|
||||
echo "Attempting to continue without running mozroots. This might fail."
|
||||
fi
|
||||
# Re-run bootstrapper whether or not the user ran mozroots, because maybe
|
||||
# they fixed the problem in a separate terminal window.
|
||||
run $PAKET_BOOTSTRAPPER_EXE
|
||||
fi
|
||||
|
||||
run $PAKET_EXE restore
|
||||
|
||||
[ ! -e build.fsx ] && run $PAKET_EXE update
|
||||
[ ! -e build.fsx ] && run $FAKE_EXE init.fsx
|
||||
run $FAKE_EXE "$@" $FSIARGS build.fsx
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
source https://nuget.org/api/v2
|
||||
|
||||
group Build
|
||||
source https://nuget.org/api/v2
|
||||
|
||||
nuget SourceLink.Fake
|
||||
nuget FAKE
|
||||
nuget FSharp.Formatting
|
||||
|
||||
github fsharp/FAKE modules/Octokit/Octokit.fsx
|
||||
|
||||
group Test
|
||||
source https://nuget.org/api/v2
|
||||
|
||||
nuget NUnit ~> 2
|
||||
nuget NUnit.Runners ~> 2
|
||||
nuget FsUnit
|
||||
nuget unquote
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
|
||||
GROUP Build
|
||||
NUGET
|
||||
remote: https://www.nuget.org/api/v2
|
||||
specs:
|
||||
FAKE (4.23.1)
|
||||
FSharp.Compiler.Service (2.0.0.6)
|
||||
FSharp.Formatting (2.14.1)
|
||||
FSharp.Compiler.Service (2.0.0.6)
|
||||
FSharpVSPowerTools.Core (>= 2.3 < 2.4)
|
||||
FSharpVSPowerTools.Core (2.3)
|
||||
FSharp.Compiler.Service (>= 2.0.0.3)
|
||||
Microsoft.Bcl (1.1.10) - framework: net10, net11, net20, net35, net40, net40-full
|
||||
Microsoft.Bcl.Build (>= 1.0.14)
|
||||
Microsoft.Bcl.Build (1.0.21) - import_targets: false, framework: net10, net11, net20, net35, net40, net40-full
|
||||
Microsoft.Net.Http (2.2.29) - framework: net10, net11, net20, net35, net40, net40-full
|
||||
Microsoft.Bcl (>= 1.1.10)
|
||||
Microsoft.Bcl.Build (>= 1.0.14)
|
||||
Octokit (0.19)
|
||||
Microsoft.Net.Http
|
||||
SourceLink.Fake (1.1)
|
||||
GITHUB
|
||||
remote: fsharp/FAKE
|
||||
specs:
|
||||
modules/Octokit/Octokit.fsx (a362ff28fc27c98f6195aab6421300e5f6c47581)
|
||||
Octokit
|
||||
GROUP Test
|
||||
NUGET
|
||||
remote: https://www.nuget.org/api/v2
|
||||
specs:
|
||||
FSharp.Core (4.0.0.1)
|
||||
FsUnit (1.4.1)
|
||||
FSharp.Core (>= 3.1.2.5)
|
||||
NUnit (2.6.4)
|
||||
NUnit (2.6.4)
|
||||
NUnit.Runners (2.6.4)
|
||||
Unquote (3.1.1)
|
|
@ -1,17 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>7dc6271f-642e-4431-bb7c-24f49a36413c</ProjectGuid>
|
||||
<ProjectGuid>5161430d-44b4-441c-be95-89c02f215d38</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Angara.Statistics</RootNamespace>
|
||||
<AssemblyName>Angara.Statistics</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
|
||||
<Name>Angara.Statistics</Name>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
|
@ -20,20 +19,36 @@
|
|||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<Tailcalls>false</Tailcalls>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>.\bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\Angara.Statistics.XML</DocumentationFile>
|
||||
<OtherFlags>--warnon:1182</OtherFlags>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Tailcalls>true</Tailcalls>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>.\bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
<DocumentationFile>bin\Release\Angara.Statistics.XML</DocumentationFile>
|
||||
<DocumentationFile>.\bin\Release\Angara.Statistics.xml</DocumentationFile>
|
||||
<OtherFlags>--warnon:1182</OtherFlags>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Statistics.fs" />
|
||||
<Compile Include="Filzbach.fs" />
|
||||
<None Include="paket.references" />
|
||||
<None Include="paket.template" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
@ -49,24 +64,13 @@
|
|||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<Import Project="$(FSharpTargetsPath)" />
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<Compile Include="Statistics.fs" />
|
||||
<Compile Include="Filzbach.fs" />
|
||||
<None Include="Scripts\load-references-debug.fsx" />
|
||||
<None Include="Scripts\load-project-debug.fsx" />
|
||||
<None Include="Scripts\load-references-release.fsx" />
|
||||
<None Include="Scripts\load-project-release.fsx" />
|
||||
<None Include="Filzbach_multispp.fsx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="..\..\.paket\paket.targets" />
|
||||
</Project>
|
|
@ -4,16 +4,22 @@ open Angara.Statistics
|
|||
[<CustomEquality>][<NoComparison>]
|
||||
type ParameterDefinition =
|
||||
{
|
||||
/// An index of the parameter in a parameter values array.
|
||||
index: int
|
||||
/// A number of values. For vector parameters 'size>1`
|
||||
size: int
|
||||
/// A lower bound of parameter values.
|
||||
lower: float
|
||||
/// An upper bound of parameter values.
|
||||
upper: float
|
||||
/// When `isLog=true` the sampler transforms the parameter to logarithmic space.
|
||||
isLog: bool
|
||||
/// If delay<1, the sampler initializes the parameter value with a random number.
|
||||
/// If delay=1, the sampler starts with the value from the definition record.
|
||||
/// If delay>1, the sampler doesn't change the parameter value for the first 'delay' iterations.
|
||||
/// If `delay<1`, the sampler initializes the parameter value with a random number.
|
||||
/// If `delay=1`, the sampler starts with the value from the definition record.
|
||||
/// If `delay>1`, the sampler doesn't change the parameter value for the first 'delay' iterations.
|
||||
delay: int
|
||||
prior: float -> float // log_pdf of prior distribution; if isLog, then the first argument of prior is log-parameter; all vector element reuse the same prior.
|
||||
/// log_pdf of prior distribution; if isLog, then the first argument of prior is log-parameter; all vector elements reuse the same prior.
|
||||
prior: float -> float
|
||||
}
|
||||
member x.isFixed = x.delay = System.Int32.MaxValue
|
||||
override x.Equals other =
|
||||
|
@ -130,16 +136,17 @@ type Parameters private (pdefs: Map<string,ParameterDefinition>, pvalues: float[
|
|||
x.Add(name, values, min (exp(logMu - 4.417 * sigma)) (Array.min values), max (exp(logMu + 4.417 * sigma)) (Array.max values), 1, true, normalPrior logMu sigma)
|
||||
| _ -> invalidArg "prior" "this method overload accepts only Uniform, LogUniform, Normal and LogNormal priors"
|
||||
|
||||
/// Compatible with parameter_create, parameter_create_vector (see Filzbach User Guide). Parameter dsply not used here.
|
||||
member x.Add(name, lb, ub, ``val``, ``type``, ``fixed``, dsply:int, ?number) =
|
||||
/// Add a parameter.
|
||||
/// This signature is compatible with `parameter_create` and `parameter_create_vector` functions
|
||||
/// described in [Filzbach User Guide](http://research.microsoft.com/en-us/um/cambridge/groups/science/tools/filzbach/filzbach%20user%20gude%20v.1.1.pdf).
|
||||
/// The `dsply` argument is not used here.
|
||||
member x.Add(name, lb:float, ub:float, ``val``:float, ``type``, ``fixed``, dsply:int, ?number) =
|
||||
let size = defaultArg number 1
|
||||
x.Add(name, Array.create size ``val``, lb, ub, (if ``fixed`` = 0 then 0 else System.Int32.MaxValue), ``type`` <> 0, uniformPrior)
|
||||
|
||||
/// Replaces all parameter values
|
||||
member x.SetValues
|
||||
/// An array of all parameters values.
|
||||
/// For a parameter 'name' the parameter values start with index '.GetDefinition(name).index' in the array.
|
||||
values =
|
||||
/// Replaces all parameter values.
|
||||
/// For a parameter `"p"` the parameter values are at index `x.GetDefinition("p").index` in the `values` array.
|
||||
member x.SetValues (values:float[]) =
|
||||
if Array.length values <> Array.length pvalues then
|
||||
invalidArg "values" "invalid length of the array."
|
||||
Parameters(pdefs, values)
|
||||
|
@ -163,7 +170,7 @@ type Parameters private (pdefs: Map<string,ParameterDefinition>, pvalues: float[
|
|||
member x.GetValues name = avalue pdefs.[name]
|
||||
|
||||
/// Get all values of all parameters.
|
||||
/// For a parameter 'name' the parameter values start with index '.GetDefinition(name).index' in the sequence.
|
||||
/// For a parameter `"p"` the parameter values are at index `x.GetDefinition("p").index` in the `values` array.
|
||||
member x.AllValues = Seq.ofArray pvalues
|
||||
|
||||
/// Total number of all parameter values.
|
||||
|
@ -175,7 +182,7 @@ type Parameters private (pdefs: Map<string,ParameterDefinition>, pvalues: float[
|
|||
/// Get a parameter name by value index.
|
||||
member x.GetName idx =
|
||||
if idx < 0 || idx >= Array.length pvalues then raise(System.IndexOutOfRangeException())
|
||||
Map.findKey (fun n d -> idx >= d.index && idx < d.index+d.size) pdefs
|
||||
Map.findKey (fun _ d -> idx >= d.index && idx < d.index+d.size) pdefs
|
||||
|
||||
interface IParameters with
|
||||
member x.Count = pdefs.Count
|
||||
|
@ -217,7 +224,7 @@ and Sampler private (logl: Parameters -> float,
|
|||
runalt:int[], // number of alterations of individual parameters
|
||||
runacc:int[] // number of accepted alterations of individual parameters
|
||||
) =
|
||||
static let log_prior pall values = Array.fold2 (fun sum d v -> d.prior v) 0. pall values
|
||||
static let log_prior pall values = Array.fold2 (fun sum d v -> sum + d.prior v) 0. pall values
|
||||
static let make_pall (pp:Parameters) =
|
||||
let pall = Array.zeroCreate pp.CountValues
|
||||
for kv in pp.definitions do
|
||||
|
@ -243,12 +250,6 @@ and Sampler private (logl: Parameters -> float,
|
|||
else 0.50*(def.upper - def.lower))
|
||||
let runalt = Array.create paramcount 0
|
||||
let runacc = Array.create paramcount 0
|
||||
// init_counters
|
||||
let metr_number_ok = 0
|
||||
let pbacc = 0
|
||||
let pbcount = 0
|
||||
// init_bayestable
|
||||
let bayestable = []
|
||||
// init_likelihood
|
||||
let ltotold = pp.SetValues values |> logl
|
||||
let ptotold = log_prior pall values
|
||||
|
@ -390,7 +391,7 @@ and Sampler private (logl: Parameters -> float,
|
|||
(samples |> Seq.map (fun {logLikelihood=logl; logPrior=logp} -> logl+logp) |> Seq.max)
|
||||
acceptanceRate
|
||||
printfn "------------+------------+------------+------------+------------+------------+------------+------------+"
|
||||
printfn " name | lower | lower 95%% | lower 68%% | median | upper 68%% | upper 95%% | upper | prior"
|
||||
printfn " name | lower | lower 95%% | lower 68%% | median | upper 68%% | upper 95%% | upper | isLog"
|
||||
printfn "------------+------------+------------+------------+------------+------------+------------+------------+"
|
||||
for idx in 0..sampler.Parameters.CountValues-1 do
|
||||
let q = qsummary (samples |> Seq.map (fun {values=sample} -> sample.[idx]))
|
||||
|
@ -401,6 +402,6 @@ and Sampler private (logl: Parameters -> float,
|
|||
(fullname.Substring(0,min 10 fullname.Length))
|
||||
pdef.lower
|
||||
q.lb95 q.lb68 q.median q.ub68 q.ub95
|
||||
pdef.upper pdef.prior
|
||||
pdef.upper pdef.isLog
|
||||
for off in 10..10..fullname.Length do
|
||||
printfn " %10s" (fullname.Substring(off,min 10 (fullname.Length-off)))
|
|
@ -6,11 +6,12 @@
|
|||
|
||||
type Distribution =
|
||||
| Uniform of float*float // lower bound, upper bound (> lower bound) -> continuous [lower bound to upper bound)
|
||||
/// A uniform distribution in log space.
|
||||
| LogUniform of float*float // lower bound (> 0), upper bound (> lower bound) -> continuous [lower bound to upper bound)
|
||||
| Normal of float*float // mean, standard deviation (> 0) -> continuous (-infinity to infinity)
|
||||
| LogNormal of float*float // log mean, standard deviation of logarithm (> 0) -> continuous (0.0 to infinity)
|
||||
| Bernoulli of float // fraction of success [1e-16 to 1.0-1e-16] -> success/failure outcome, 1 or 0
|
||||
/// the number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p.
|
||||
/// A number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p.
|
||||
| Binomial of int*float // number of trials, probability of success -> number of successes, [0 to max_int]
|
||||
| NegativeBinomial of float*float // mean (0 to inf), number of failures or 'shape' for fractional values (0 to inf) -> number of successes, [0 to max_int]
|
||||
| Poisson of float // mean a.k.a. lambda [0, maxint] -> number of events [0 to maxint]
|
||||
|
@ -18,14 +19,17 @@ type Distribution =
|
|||
| Exponential of float // rate lambda (>0) -> continuaous [0 to infinity)
|
||||
| Mixture of (float*Distribution) list
|
||||
|
||||
/// The smallest positive normalized `float` value
|
||||
let improbable = 2.2250738585072014E-308 // 2^(-1022)
|
||||
/// Logarithm of `improbable`
|
||||
let log_improbable = log(improbable) // -708
|
||||
|
||||
/// 1.0 - tolerance < 1.0 && 1.0 - 0.5*tolerance = 1.0
|
||||
/// `1.0 - tolerance < 1.0 && 1.0 - 0.5*tolerance = 1.0`
|
||||
let tolerance = 1.1102230246251565E-16 // 2^(-53)
|
||||
/// Logarithm of `tolerance`
|
||||
let log_tolerance = log(tolerance) // -36.7
|
||||
|
||||
/// maxint+1.0 = maxint && maxint-1.0 < maxint
|
||||
/// Maximum exact integer `maxint+1.0 = maxint && maxint-1.0 < maxint`
|
||||
let maxint = 1.0/tolerance; // 9e15 -- 6 orders of magnitude alrger than int.maxvalue
|
||||
|
||||
/// π
|
||||
|
@ -37,7 +41,10 @@ let pi2 = 6.283185307179586476925286
|
|||
/// natural logarithm base
|
||||
let e = 2.71828182845904523536028747135266250
|
||||
|
||||
/// sqrt 2π
|
||||
let sqrt2pi = sqrt(pi2)
|
||||
|
||||
/// 1/2 * log 2π
|
||||
let log2pi = 0.5*log(pi2)
|
||||
|
||||
let private isNan = System.Double.IsNaN
|
||||
|
@ -109,14 +116,14 @@ let private log_gamma x =
|
|||
t+log(2.5066282746310005*ser/x)
|
||||
|
||||
// adopted from "Fast and Accurate Computation of Binomial Probabilities", C. Loader, 2000
|
||||
let sfe = Seq.unfold (fun (n, lognf) ->
|
||||
if n=0 then
|
||||
Some(0.0, (1,0.0))
|
||||
elif n<16 then
|
||||
let logn = log(float n)
|
||||
Some(lognf+float(n)-log2pi-(float(n)-0.5)*logn, (n+1, lognf+logn))
|
||||
else None) (0, 0.0) |> Array.ofSeq
|
||||
|
||||
let private sfe =
|
||||
Seq.unfold (fun (n, lognf) ->
|
||||
if n=0 then
|
||||
Some(0.0, (1,0.0))
|
||||
elif n<16 then
|
||||
let logn = log(float n)
|
||||
Some(lognf+float(n)-log2pi-(float(n)-0.5)*logn, (n+1, lognf+logn))
|
||||
else None) (0, 0.0) |> Array.ofSeq
|
||||
|
||||
let private stirlerr n =
|
||||
if (n<16) then sfe.[n]
|
||||
|
@ -160,7 +167,8 @@ let private dpois(x: int, lb: float) =
|
|||
elif (x=0) then exp(-lb)
|
||||
else exp(-stirlerr(x)-bd0(float x,lb))/sqrt(pi2*float(x));
|
||||
|
||||
let rec log_pdf d v = // log-probability distribution function
|
||||
/// Logarithm of a Probability Distribution Function
|
||||
let rec log_pdf d v =
|
||||
if System.Double.IsNaN(v) then log_improbable
|
||||
else
|
||||
let result =
|
||||
|
@ -605,7 +613,7 @@ let correlation (x:float[]) (y:float[]) =
|
|||
// adopted from MathNet.Numerics
|
||||
// https://github.com/mathnet/mathnet-numerics/blob/v3.9.0/src/Numerics/IntegralTransforms/Fourier.RadixN.cs
|
||||
|
||||
type Complex = System.Numerics.Complex
|
||||
open System.Numerics
|
||||
|
||||
let private InverseScaleByOptions(samples:Complex[]) =
|
||||
let scalingFactor = 1.0/(float samples.Length)
|
||||
|
@ -618,7 +626,7 @@ let private ForwardScaleByOptions(samples:Complex[]) =
|
|||
samples.[i] <- samples.[i] * Complex(scalingFactor, 0.)
|
||||
|
||||
|
||||
let Radix2Reorder(samples:'T[]) =
|
||||
let private Radix2Reorder(samples:'T[]) =
|
||||
let mutable j = 0
|
||||
for i in 0..samples.Length - 2 do
|
||||
if (i < j) then
|
||||
|
@ -633,7 +641,7 @@ let Radix2Reorder(samples:'T[]) =
|
|||
j <- j ^^^ m;
|
||||
cont <- (j &&& m) = 0
|
||||
|
||||
let Radix2Step(samples:Complex[], exponentSign:int, levelSize:int, k:int) =
|
||||
let private Radix2Step(samples:Complex[], exponentSign:int, levelSize:int, k:int) =
|
||||
// Twiddle Factor
|
||||
let exponent = (float exponentSign*float k)*pi/float levelSize
|
||||
let w = Complex(cos(exponent), sin(exponent))
|
||||
|
@ -644,7 +652,7 @@ let Radix2Step(samples:Complex[], exponentSign:int, levelSize:int, k:int) =
|
|||
samples.[i] <- ai + t
|
||||
samples.[i + levelSize] <- ai - t
|
||||
|
||||
let Radix2(samples:Complex[], exponentSign:int) =
|
||||
let private Radix2(samples:Complex[], exponentSign:int) =
|
||||
let rec is_power_two x p =
|
||||
if x = p then true
|
||||
elif x < p then false
|
||||
|
@ -660,10 +668,8 @@ let Radix2(samples:Complex[], exponentSign:int) =
|
|||
|
||||
|
||||
let private fi x = float(x)
|
||||
let _i_ = Complex.ImaginaryOne
|
||||
let _ip_ = Complex(0.0,1.0)
|
||||
|
||||
/// Inverse FFT
|
||||
/// Inverse Fast Fourier Transform.
|
||||
let ifft (xs:Complex[]) =
|
||||
let samples = Array.copy xs
|
||||
Radix2(samples,1)
|
||||
|
@ -673,14 +679,15 @@ let ifft (xs:Complex[]) =
|
|||
samples.[i] <- Complex(scalingFactor * v.Real, scalingFactor * v.Imaginary)
|
||||
samples
|
||||
|
||||
/// Fast Fourier transform
|
||||
/// Fast Fourier transform.
|
||||
let fft (xs:Complex[]) =
|
||||
let samples = Array.copy xs
|
||||
Radix2(samples,-1)
|
||||
samples
|
||||
|
||||
let (|Even|Odd|) input = if input % 2 = 0 then Even else Odd
|
||||
let private (|Even|Odd|) input = if input % 2 = 0 then Even else Odd
|
||||
|
||||
/// Descrete cosine transform.
|
||||
let dct (rxs:float[]) =
|
||||
let xs = Array.map (fun x -> Complex(x,0.0)) rxs
|
||||
let len = xs.Length
|
||||
|
@ -697,7 +704,7 @@ let dct (rxs:float[]) =
|
|||
Array.map2 (fun (a:Complex) (b:Complex) -> (a*b).Real) weights (fft interleaved)
|
||||
|
||||
|
||||
// Inverse discrete cosine transform.
|
||||
/// Inverse discrete cosine transform.
|
||||
// idct :: U.Vector CD -> U.Vector Double
|
||||
// http://hackage.haskell.org/package/statistics-0.10.0.0/docs/src/Statistics-Transform.html
|
||||
let idct (rxs:float[]) =
|
||||
|
@ -720,7 +727,7 @@ let idct (rxs:float[]) =
|
|||
// Efficiently compute the next highest power of two for a
|
||||
// non-negative integer. If the given value is already a power of
|
||||
// two, it is returned unchanged. If negative, zero is returned.
|
||||
let nextHighestPowerOfTwo n =
|
||||
let private nextHighestPowerOfTwo n =
|
||||
let i0 = n - 1
|
||||
let i1 = i0 ||| (i0 >>> 1)
|
||||
let i2 = i1 ||| (i1 >>> 2)
|
||||
|
@ -746,7 +753,7 @@ let histogram_ n xmin xmax xs =
|
|||
h
|
||||
|
||||
/// Approximate comparison of two double values.
|
||||
/// Tolerance ulps is in units of least precision.
|
||||
/// Tolerance `ulps` is in units of least precision.
|
||||
let within (ulps:uint32) a b =
|
||||
// See e.g. "Comparing Floating Point Numbers, 2012 Edition" by Bruce Dawson
|
||||
// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||
|
@ -757,7 +764,7 @@ let within (ulps:uint32) a b =
|
|||
elif ai>=0L && bi<0L then cmp ai (System.Int64.MinValue-bi)
|
||||
else cmp ai bi
|
||||
|
||||
/// Use the method of Ridders to compute a root of a function.
|
||||
/// Root of a function using Ridders method.
|
||||
// Ridders, C.F.J. (1979) A new algorithm for computing a single
|
||||
// root of a real continuous function.
|
||||
// /IEEE Transactions on Circuits and Systems/ 26:979--980.
|
||||
|
@ -780,7 +787,7 @@ let ridders tolerance (lb, ub) (f : float->float) =
|
|||
if d < tolerance then Some n else
|
||||
if n=a || n=b then
|
||||
// Ridder's approximation coincide with one of old bounds. Revert to bisection
|
||||
if 0.0 > fm*fa then iter a fa m fm (i+1)
|
||||
if 0 > sign fm * sign fa then iter a fa m fm (i+1)
|
||||
else iter m fm b fb (i+1)
|
||||
else
|
||||
let fn = f n
|
||||
|
@ -799,8 +806,8 @@ let ridders tolerance (lb, ub) (f : float->float) =
|
|||
|
||||
// from http://hackage.haskell.org/package/statistics-0.10.5.0/docs/src/Statistics-Sample-KernelDensity.html#kde
|
||||
//
|
||||
// Gaussian kernel density estimator for one-dimensional data, using
|
||||
// the method of Botev et al.
|
||||
/// Gaussian kernel density estimator for one-dimensional data, using
|
||||
/// the method of Botev et al.
|
||||
//
|
||||
// Botev. Z.I., Grotowski J.F., Kroese D.P. (2010). Kernel density estimation via diffusion.
|
||||
// /Annals of Statistics/ 38(5):2916-2957. <http://arxiv.org/pdf/1011.2602>
|
||||
|
@ -867,8 +874,8 @@ let kde2 n0 min max (sample:float seq) =
|
|||
a0
|
||||
(mesh, density)
|
||||
|
||||
// Gaussian kernel density estimator for one-dimensional data, using
|
||||
// the method of Botev et al.
|
||||
/// Gaussian kernel density estimator for one-dimensional data, using
|
||||
/// the method of Botev et al.
|
||||
//
|
||||
// The result is a pair of vectors, containing:
|
||||
//
|
|
@ -0,0 +1,25 @@
|
|||
type project
|
||||
title
|
||||
##ProjectName##
|
||||
owners
|
||||
Vassily Lyutsarev
|
||||
authors
|
||||
Vassily Lyutsarev
|
||||
projectUrl
|
||||
http://github.com/microsoft/Angara.Statistics
|
||||
iconUrl
|
||||
https://raw.githubusercontent.com/microsoft/Angara.Statistics/master/docs/files/img/logo.png
|
||||
licenseUrl
|
||||
http://github.com/microsoft/Angara.Statistics/blob/master/LICENSE.txt
|
||||
requireLicenseAcceptance
|
||||
false
|
||||
copyright
|
||||
Copyright 2015
|
||||
tags
|
||||
statistics probability fsharp
|
||||
summary
|
||||
A collection of statistics algorithms from Mersenne twister generator to MCMC sampling.
|
||||
description
|
||||
Includes Mersenne twister random number generator, common probability distributions, statistics and quantiles, kernel density estimator, Metropolis-Hastings MCMC sampler.
|
||||
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>d5620a55-aa34-4de7-a970-b2168a06d28d</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Angara.Statistics.Tests</RootNamespace>
|
||||
<AssemblyName>Angara.Statistics.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
|
||||
<Name>Angara.Statistics.Tests</Name>
|
||||
<TargetFrameworkProfile />
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<Tailcalls>false</Tailcalls>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
<StartAction>Project</StartAction>
|
||||
<StartProgram>
|
||||
</StartProgram>
|
||||
<StartArguments>
|
||||
</StartArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Tailcalls>true</Tailcalls>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<WarningLevel>3</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '11.0'">
|
||||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
|
||||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
|
||||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<Import Project="$(FSharpTargetsPath)" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<ItemGroup>
|
||||
<Compile Include="Tests.fs" />
|
||||
<Compile Include="FilzbachTests.fs" />
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Angara.Statistics\Angara.Statistics.fsproj">
|
||||
<Name>Angara.Statistics</Name>
|
||||
<Project>{5161430d-44b4-441c-be95-89c02f215d38}</Project>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<Import Project="..\..\.paket\paket.targets" />
|
||||
<Choose>
|
||||
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1')">
|
||||
<ItemGroup>
|
||||
<Reference Include="FsUnit.NUnit">
|
||||
<HintPath>..\..\packages\test\FsUnit\lib\net45\FsUnit.NUnit.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Paket>True</Paket>
|
||||
</Reference>
|
||||
<Reference Include="NHamcrest">
|
||||
<HintPath>..\..\packages\test\FsUnit\lib\net45\NHamcrest.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Paket>True</Paket>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\..\packages\test\NUnit\lib\nunit.framework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Paket>True</Paket>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
|
||||
<ItemGroup>
|
||||
<Reference Include="Unquote">
|
||||
<HintPath>..\..\packages\test\Unquote\lib\net40\Unquote.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Paket>True</Paket>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1')">
|
||||
<ItemGroup>
|
||||
<Reference Include="Unquote">
|
||||
<HintPath>..\..\packages\test\Unquote\lib\net45\Unquote.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Paket>True</Paket>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkIdentifier) == '.NETCore') Or ($(TargetFrameworkIdentifier) == 'WindowsPhone' And ($(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1')) Or ($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch') Or ($(TargetFrameworkIdentifier) == 'Xamarin.iOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.Mac') Or ($(TargetFrameworkProfile) == 'Profile7') Or ($(TargetFrameworkProfile) == 'Profile31') Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkProfile) == 'Profile44') Or ($(TargetFrameworkProfile) == 'Profile49') Or ($(TargetFrameworkProfile) == 'Profile78') Or ($(TargetFrameworkProfile) == 'Profile84') Or ($(TargetFrameworkProfile) == 'Profile111') Or ($(TargetFrameworkProfile) == 'Profile151') Or ($(TargetFrameworkProfile) == 'Profile157') Or ($(TargetFrameworkProfile) == 'Profile259')">
|
||||
<ItemGroup>
|
||||
<Reference Include="Unquote">
|
||||
<HintPath>..\..\packages\test\Unquote\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1\Unquote.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Paket>True</Paket>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
</Project>
|
|
@ -1,6 +1,7 @@
|
|||
module statistics.Tests
|
||||
open NUnit.Framework
|
||||
open FsUnit
|
||||
open Swensen.Unquote.Assertions
|
||||
type Complex = System.Numerics.Complex
|
||||
|
||||
open Angara.Statistics
|
||||
|
@ -119,38 +120,33 @@ let within_tests() =
|
|||
|
||||
[<Test>]
|
||||
let ridders_tests() =
|
||||
ridders 0. (-1.0, -2.0) (fun x -> x) |> should equal None
|
||||
ridders 0. (1.0, 2.0) (fun x -> x) |> should equal None
|
||||
ridders 0. (-2.0, -1.0) (fun x -> x) |> should equal None
|
||||
ridders 0. (2.0, 1.0) (fun x -> x) |> should equal None
|
||||
ridders 0. (1.0, 0.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 0. (0.0, 1.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 0. (-1.0, 1.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 0. (1.0, -1.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 0. (-1.0, -2.0) (fun x -> x) =! None
|
||||
ridders 0. (1.0, 2.0) (fun x -> x) =! None
|
||||
ridders 0. (-2.0, -1.0) (fun x -> x) =! None
|
||||
ridders 0. (2.0, 1.0) (fun x -> x) =! None
|
||||
ridders 0. (1.0, 0.0) (fun x -> x) =! (Some 0.0)
|
||||
ridders 0. (0.0, 1.0) (fun x -> x) =! (Some 0.0)
|
||||
ridders 0. (-1.0, 1.0) (fun x -> x) =! (Some 0.0)
|
||||
ridders 0. (1.0, -1.0) (fun x -> x) =! (Some 0.0)
|
||||
// for linear function the solution is exact on the first iteration
|
||||
ridders 0. (-1.0, 2.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 1e-5 (-1.0, 2.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 0. (1.0, -2.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 1e-5 (1.0, -2.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
ridders 0. (-1.0, 2.0) (fun x -> x) =! (Some 0.0)
|
||||
ridders 1e-5 (-1.0, 2.0) (fun x -> x) =! (Some 0.0)
|
||||
ridders 0. (1.0, -2.0) (fun x -> x) =! (Some 0.0)
|
||||
ridders 1e-5 (1.0, -2.0) (fun x -> x) =! (Some 0.0)
|
||||
// quadratic function is well-behaved
|
||||
ridders 0. (0.5, 2.0) (fun x -> x * (x-1.)) |> should equal (Some 1.0)
|
||||
ridders 1e-5 (-1.0, 2.0) (fun x -> x) |> should equal (Some 0.0)
|
||||
match ridders 1e-3 (0.5, 2.0) (fun x -> x * (x-1.)) with
|
||||
| None -> Assert.Fail "should not be None"
|
||||
| Some v -> v |> should (equalWithin 1e-3) 1.0
|
||||
match ridders 1e-15 (0.5, 2.0) (fun x -> x * (x-1.)) with
|
||||
| None -> Assert.Fail "should not be None"
|
||||
| Some v -> v |> should (equalWithin 1e-15) 1.0
|
||||
ridders 0. (0.5, 2.0) (fun x -> x * (x-1.)) =! (Some 1.0)
|
||||
ridders 1e-5 (-1.0, 2.0) (fun x -> x) =! (Some 0.0)
|
||||
let t1 = ridders 1e-3 (0.5, 2.0) (fun x -> x * (x-1.))
|
||||
test <@ t1.IsSome && abs(t1.Value - 1.0) < 1e-3 @>
|
||||
let t2 = ridders 1e-15 (0.5, 2.0) (fun x -> x * (x-1.))
|
||||
test <@ t2.IsSome && abs(t2.Value - 1.0) < 1e-15 @>
|
||||
// check exit by within 1u
|
||||
match ridders 0.0 (0.5, 2.0) (fun x -> if x < 1. then -1.0 else 1.0) with
|
||||
| None -> Assert.Fail "should not be None"
|
||||
| Some v ->
|
||||
v |> should not' (equal 1.)
|
||||
within 1u v 1. |> should be True
|
||||
let t3 = ridders 0.0 (0.5, 2.0) (fun x -> if x < 1. then -1.0 else 1.0)
|
||||
test <@ t3.IsSome && t3.Value <> 1.0 && within 1u t3.Value 1. @>
|
||||
// check bisection branch when discriminant vanishes to 0
|
||||
match ridders 0.0 (0.5, 2.0) (fun x -> (sqrt System.Double.Epsilon) * (x-1.)) with
|
||||
| None -> Assert.Fail "should not be None"
|
||||
| Some v -> within 1u v 1. |> should be True
|
||||
let f4 x = (sqrt System.Double.Epsilon) * (x-1.)
|
||||
let t4 = ridders 0.0 (0.5, 2.0) f4
|
||||
test <@ t4.IsSome && within 1u t4.Value 1. @>
|
||||
|
||||
|
||||
[<Test>]
|
||||
|
@ -199,3 +195,7 @@ let KernelDensityEstimation_Normal() =
|
|||
0.40621277696505254
|
||||
|]
|
||||
y |> should (equalWithin 1.e-12) ys'
|
||||
[<Test>]
|
||||
let const_tests() =
|
||||
test <@ maxint+1.0 = maxint && maxint-1.0 < maxint @>
|
||||
test <@ 1.0 - tolerance < 1.0 && 1.0 - 0.5*tolerance = 1.0 @>
|
|
@ -0,0 +1,5 @@
|
|||
group Test
|
||||
NUnit
|
||||
NUnit.Runners
|
||||
FsUnit
|
||||
Unquote
|
Загрузка…
Ссылка в новой задаче