
FSharp.Stats is a multipurpose project for statistical testing, linear algebra, machine learning, fitting and signal processing.
From Nuget.org:
You can get all FSharp.Stats packages from nuget at https://www.nuget.org/packages/FSharp.Stats/.
To build the binaries yourself:
Windows:
- Install .Net Core SDK
- navigate to project folder
- use the console command
./build.cmd
Linux(Ubuntu, using Mono):
- Install .Net Core SDK
- navigate to project folder
- make the script executable with
chmod +x ./build.sh
- use the console command
./build.sh
The following examples show how easy it is to start working with FSharp.Stats.
open FSharp.Stats
// initialize a normal distribution with mean 25 and standard deviation 0.1
let normalDistribution = Distributions.Continuous.normal 25. 0.1
// draw independently 30 times from the given distribution
let sample = Array.init 30 (fun _ -> normalDistribution.Sample())
[|25.01546996; 25.0085751; 24.98655087; 24.97754422; 25.06064294; 25.12730136;
25.15369078; 25.16191506; 25.09960277; 24.9804254; 24.84672728; 24.98691456;
24.97149665; 24.86228433; 24.88944442; 25.07089216; 24.98596124; 25.03055411;
25.05189345; 25.15010645; 24.98942086; 25.12237777; 24.78971587; 25.04044524;
25.06452394; 25.02869547; 24.94641875; 24.78399431; 24.75855518; 24.9933029|]
|
// calculate the mean of the given sample
let mean = Seq.mean sample
// calculate the bessel corrected sample standard deviation of the given sample
let stDev = Seq.stDev sample
// calculate the coefficient of variation of the given sample
// Attention: CV is valid only if a hypothetical real zero value exists for the data.
let cv = Seq.cv sample
// create a vector
let vecB = vector [19.;11.;35.]
// create a matrix
let matA = matrix [[3.;4.;0.];[1.;2.;2.];[5.;0.;5.]]
// solve the linear system of equations
let vecX = FSharp.Stats.Algebra.LinearAlgebra.SolveLinearSystem matA vecB
let xData = vector [|1. .. 10.|]
let yData = vector [|4.;7.;9.;12.;15.;17.;16.;23.;5.;30.|]
// get coefficients of interpolating polynomial
let interpolatingCoefficients =
Interpolation.Polynomial.coefficients xData yData
// get fitting function of interpolating polynomial
let interpolFitFunc =
Interpolation.Polynomial.fit interpolatingCoefficients
// get coefficients of 3rd order regression polynomial
let regressionCoefficients =
Fitting.LinearRegression.OrdinaryLeastSquares.Polynomial.coefficient 3 xData yData
// get fitting function of 3rd order regression polynomial
let regressionFitFunc =
Fitting.LinearRegression.OrdinaryLeastSquares.Polynomial.fit 3 regressionCoefficients
The resulting interpolating and regression polynomials are plotted below using Plotly.NET.
The library comes with comprehensible documentation.
It can include tutorials automatically generated from *.fsx
files in the content folder.
The API reference is automatically generated from Markdown comments in the library implementation.
-
API Reference contains automatically generated documentation for all types, modules
and functions in the library. This includes additional brief samples on using most of the
functions.
The project is hosted on GitHub where you can report issues, fork
the project and submit pull requests. If you're adding a new public API, please also
consider adding samples that can be turned into a documentation. You might
also want to read the library design notes to understand how it works.
The library is available under Public Domain license, which allows modification and
redistribution for both commercial and non-commercial purposes. For more information see the
License file in the GitHub repository.
namespace Plotly
namespace Plotly.NET
module Axis
from Plotly.NET
module StyleParam
from Plotly.NET
val myAxis : title:string -> LinearAxis
val title : string
Multiple items
type LinearAxis =
inherit DynamicObj
new : unit -> LinearAxis
static member init : ?AxisType:AxisType * ?Title:string * ?Titlefont:Font * ?Autorange:AutoRange * ?Rangemode:RangeMode * ?Range:Range * ?RangeSlider:RangeSlider * ?Fixedrange:'a * ?Tickmode:TickMode * ?nTicks:'b * ?Tick0:'c * ?dTick:'d * ?Tickvals:'e * ?Ticktext:'f * ?Ticks:TickOptions * ?Mirror:Mirror * ?Ticklen:'g * ?Tickwidth:'h * ?Tickcolor:'i * ?Showticklabels:'j * ?Tickfont:Font * ?Tickangle:'k * ?Tickprefix:'l * ?Showtickprefix:ShowTickOption * ?Ticksuffix:'m * ?Showticksuffix:ShowTickOption * ?Showexponent:ShowExponent * ?Exponentformat:ExponentFormat * ?Tickformat:'n * ?Hoverformat:'o * ?Showline:bool * ?Linecolor:'p * ?Linewidth:'q * ?Showgrid:bool * ?Gridcolor:'r * ?Gridwidth:'s * ?Zeroline:bool * ?Zerolinecolor:'t * ?Zerolinewidth:'a1 * ?Anchor:AxisAnchorId * ?Side:Side * ?Overlaying:AxisAnchorId * ?Domain:Range * ?Position:float * ?IsSubplotObj:'a2 * ?Tickvalssrc:'a3 * ?Ticktextsrc:'a4 * ?Showspikes:'a5 * ?Spikesides:'a6 * ?Spikethickness:'a7 * ?Spikecolor:'a8 * ?Showbackground:'a9 * ?Backgroundcolor:'a10 * ?Showaxeslabels:'a11 -> LinearAxis
static member style : ?AxisType:AxisType * ?Title:string * ?Titlefont:Font * ?Autorange:AutoRange * ?Rangemode:RangeMode * ?Range:Range * ?RangeSlider:RangeSlider * ?Fixedrange:'a * ?Tickmode:TickMode * ?nTicks:'b * ?Tick0:'c * ?dTick:'d * ?Tickvals:'e * ?Ticktext:'f * ?Ticks:TickOptions * ?Mirror:Mirror * ?Ticklen:'g * ?Tickwidth:'h * ?Tickcolor:'i * ?Showticklabels:'j * ?Tickfont:Font * ?Tickangle:'k * ?Tickprefix:'l * ?Showtickprefix:ShowTickOption * ?Ticksuffix:'m * ?Showticksuffix:ShowTickOption * ?Showexponent:ShowExponent * ?Exponentformat:ExponentFormat * ?Tickformat:'n * ?Hoverformat:'o * ?Showline:bool * ?Linecolor:'p * ?Linewidth:'q * ?Showgrid:bool * ?Gridcolor:'r * ?Gridwidth:'s * ?Zeroline:bool * ?Zerolinecolor:'t * ?Zerolinewidth:'a1 * ?Anchor:AxisAnchorId * ?Side:Side * ?Overlaying:AxisAnchorId * ?Domain:Range * ?Position:float * ?IsSubplotObj:'a2 * ?Tickvalssrc:'a3 * ?Ticktextsrc:'a4 * ?Showspikes:'a5 * ?Spikesides:'a6 * ?Spikethickness:'a7 * ?Spikecolor:'a8 * ?Showbackground:'a9 * ?Backgroundcolor:'a10 * ?Showaxeslabels:'a11 -> (LinearAxis -> LinearAxis)
--------------------
new : unit -> LinearAxis
static member LinearAxis.init : ?AxisType:AxisType * ?Title:string * ?Titlefont:Font * ?Autorange:AutoRange * ?Rangemode:RangeMode * ?Range:Range * ?RangeSlider:RangeSlider * ?Fixedrange:'a * ?Tickmode:TickMode * ?nTicks:'b * ?Tick0:'c * ?dTick:'d * ?Tickvals:'e * ?Ticktext:'f * ?Ticks:TickOptions * ?Mirror:Mirror * ?Ticklen:'g * ?Tickwidth:'h * ?Tickcolor:'i * ?Showticklabels:'j * ?Tickfont:Font * ?Tickangle:'k * ?Tickprefix:'l * ?Showtickprefix:ShowTickOption * ?Ticksuffix:'m * ?Showticksuffix:ShowTickOption * ?Showexponent:ShowExponent * ?Exponentformat:ExponentFormat * ?Tickformat:'n * ?Hoverformat:'o * ?Showline:bool * ?Linecolor:'p * ?Linewidth:'q * ?Showgrid:bool * ?Gridcolor:'r * ?Gridwidth:'s * ?Zeroline:bool * ?Zerolinecolor:'t * ?Zerolinewidth:'a1 * ?Anchor:AxisAnchorId * ?Side:Side * ?Overlaying:AxisAnchorId * ?Domain:Range * ?Position:float * ?IsSubplotObj:'a2 * ?Tickvalssrc:'a3 * ?Ticktextsrc:'a4 * ?Showspikes:'a5 * ?Spikesides:'a6 * ?Spikethickness:'a7 * ?Spikecolor:'a8 * ?Showbackground:'a9 * ?Backgroundcolor:'a10 * ?Showaxeslabels:'a11 -> LinearAxis
type Mirror =
| True
| Ticks
| False
| All
| AllTicks
static member convert : (Mirror -> obj)
static member toString : (Mirror -> string)
union case Mirror.All: Mirror
type TickOptions =
| Outside
| Inside
| Empty
static member convert : (TickOptions -> obj)
static member toString : (TickOptions -> string)
union case TickOptions.Inside: TickOptions
val styleChart : xt:string -> yt:string -> c:GenericChart.GenericChart -> GenericChart.GenericChart
val xt : string
val yt : string
val c : GenericChart.GenericChart
type Chart =
static member Area : xy:seq<#IConvertible * #IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:'a2 -> GenericChart
static member Area : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:'a2 -> GenericChart
static member Bar : keysvalues:seq<#IConvertible * #IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart
static member Bar : keys:seq<#IConvertible> * values:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:'a2 * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart
static member BoxPlot : xy:seq<'a0 * 'a1> * ?Name:string * ?Showlegend:bool * ?Color:string * ?Fillcolor:'a2 * ?Opacity:float * ?Whiskerwidth:'a3 * ?Boxpoints:Boxpoints * ?Boxmean:BoxMean * ?Jitter:'a4 * ?Pointpos:'a5 * ?Orientation:Orientation * ?Marker:Marker * ?Line:Line * ?Alignmentgroup:'a6 * ?Offsetgroup:'a7 * ?Notched:bool * ?NotchWidth:float * ?QuartileMethod:QuartileMethod -> GenericChart
static member BoxPlot : ?x:'a0 * ?y:'a1 * ?Name:string * ?Showlegend:bool * ?Color:string * ?Fillcolor:'a2 * ?Opacity:float * ?Whiskerwidth:'a3 * ?Boxpoints:Boxpoints * ?Boxmean:BoxMean * ?Jitter:'a4 * ?Pointpos:'a5 * ?Orientation:Orientation * ?Marker:Marker * ?Line:Line * ?Alignmentgroup:'a6 * ?Offsetgroup:'a7 * ?Notched:bool * ?NotchWidth:float * ?QuartileMethod:QuartileMethod -> GenericChart
static member Bubble : xysizes:seq<#IConvertible * #IConvertible * #IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart
static member Bubble : x:seq<#IConvertible> * y:seq<#IConvertible> * sizes:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart
static member Candlestick : stockTimeSeries:seq<DateTime * StockData> * ?Increasing:Line * ?Decreasing:Line * ?WhiskerWidth:float * ?Line:Line * ?XCalendar:Calendar -> GenericChart
static member Candlestick : open:seq<#IConvertible> * high:seq<#IConvertible> * low:seq<#IConvertible> * close:seq<#IConvertible> * x:seq<#IConvertible> * ?Increasing:Line * ?Decreasing:Line * ?WhiskerWidth:float * ?Line:Line * ?XCalendar:Calendar -> GenericChart
...
static member Chart.withX_Axis : xAxis:LinearAxis * ?Id:int -> (GenericChart.GenericChart -> GenericChart.GenericChart)
static member Chart.withY_Axis : yAxis:LinearAxis * ?Id:int -> (GenericChart.GenericChart -> GenericChart.GenericChart)
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp.Stats
val normalDistribution : Distributions.Distribution<float,float>
namespace FSharp.Stats.Distributions
module Continuous
from FSharp.Stats.Distributions
val normal : mu:float -> sigma:float -> Distributions.Distribution<float,float>
val sample : float []
Multiple items
module Array
from FSharp.Stats
--------------------
module Array
from Microsoft.FSharp.Collections
val init : count:int -> initializer:(int -> 'T) -> 'T []
abstract member Distributions.Distribution.Sample : unit -> 'b
val mean : float
Multiple items
module Seq
from FSharp.Stats
--------------------
module Seq
from Plotly.NET
--------------------
module Seq
from Microsoft.FSharp.Collections
val mean : items:seq<'T> -> 'U (requires member ( + ) and member get_Zero and member DivideByInt and member ( / ))
val stDev : float
val stDev : items:seq<'T> -> 'U (requires member ( - ) and member get_Zero and member DivideByInt and member ( + ) and member ( * ) and member ( + ) and member ( / ) and member Sqrt)
val cv : float
val cv : items:seq<'T> -> 'U (requires member ( - ) and member get_Zero and member DivideByInt and member ( + ) and member ( * ) and member Sqrt and member ( + ) and member ( / ) and member ( / ))
val vecB : Vector<float>
Multiple items
val vector : l:seq<float> -> Vector<float>
--------------------
type vector = Vector<float>
val matA : Matrix<float>
Multiple items
val matrix : ll:seq<#seq<float>> -> Matrix<float>
--------------------
type matrix = Matrix<float>
val vecX : Vector<float>
namespace FSharp.Stats.Algebra
module LinearAlgebra
from FSharp.Stats.Algebra
val SolveLinearSystem : A:matrix -> b:vector -> Vector<float>
val xData : Vector<float>
val yData : Vector<float>
val interpolatingCoefficients : Vector<float>
namespace FSharp.Stats.Interpolation
module Polynomial
from FSharp.Stats.Interpolation
val coefficients : xData:Vector<float> -> yData:Vector<float> -> Vector<float>
val interpolFitFunc : (float -> float)
val fit : coef:Vector<float> -> x:float -> float
val interpolChart : GenericChart.GenericChart
Multiple items
module List
from FSharp.Stats
--------------------
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IReadOnlyList<'T>
interface IReadOnlyCollection<'T>
interface IEnumerable
interface IEnumerable<'T>
member GetReverseIndex : rank:int * offset:int -> int
member GetSlice : startIndex:int option * endIndex:int option -> 'T list
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
...
val map : mapping:('T -> 'U) -> list:'T list -> 'U list
val x : float
val data : (float * float) list
static member Chart.Line : xy:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:'c * ?Width:'d * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart.GenericChart
static member Chart.Line : x:seq<#System.IConvertible> * y:seq<#System.IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:'a2 * ?Width:'a3 * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart.GenericChart
val regressionCoefficients : Vector<float>
namespace FSharp.Stats.Fitting
module LinearRegression
from FSharp.Stats.Fitting
module OrdinaryLeastSquares
from FSharp.Stats.Fitting.LinearRegression
module Polynomial
from FSharp.Stats.Fitting.LinearRegression.OrdinaryLeastSquares
val coefficient : order:int -> xData:Vector<float> -> yData:Vector<float> -> Vector<float>
val regressionFitFunc : (float -> float)
val fit : order:int -> coef:Vector<float> -> x:float -> float
val regressionChart : GenericChart.GenericChart
val combinedChart : GenericChart.GenericChart
val rawChart : GenericChart.GenericChart
static member Chart.Point : xy:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart.GenericChart
static member Chart.Point : x:seq<#System.IConvertible> * y:seq<#System.IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<string> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart.GenericChart
static member Chart.Combine : gCharts:seq<GenericChart.GenericChart> -> GenericChart.GenericChart
module GenericChart
from Plotly.NET
val toChartHTML : gChart:GenericChart.GenericChart -> string