Distributions
A Distribution
is a value which allows to draw
a pseudo-random number or compute a probability density function log_pdf
.
The Distribution
discriminated union supports most common probability distributions like Uniform
or Normal
.
More details are in a separate document page.
For example, here is how you define normal distribution once you've referenced Angara.Statistics.dll:
1: 2: 3: |
|
Random number generator
To draw random numbers we use Mersenne Twister, one of the most commonly used random number generator.
1: 2: 3: 4: 5: |
|
|
To reproduce the generator state use either exact seed or copy-constructor:
1: 2: 3: 4: 5: 6: |
|
|
To draw a number from a non-standard distribution use draw : MT19337 -> Distribution -> float
.
For example, here we generate an array of 1000 random numbers from the above distribution.
1:
|
|
Probability density function
One single function log_pdf : Distribution -> float -> float
computes logarithm of normalized probability density
of any distribution at any valid point.
If you do not have a Distribution but have a sample from the distribution used kernel density estimator
kde : int -> float seq -> (float[] * float[])
. The estimator needs target number of points at which the density is to be evaluated.
If this number is not a power of two he number of points will be the next larger power of two. The estimator returns two arrays of x
and y
values:
The following sample code compares non-parametric density of the sample with the exact density from log_pdf
function.
1: 2: 3: 4: 5: 6: 7: 8: 9: |
|
Sample statistics
Use summary
and qsummary
functions to quickly compute mean, standard deviation, 95% and 68% quantiles of a sample:
1:
|
|
|
1:
|
|
|
The lb95
in the qsummary
record stands for "lower bound of 95% interval" with is actually a 2.5% quantile. Similarly ub95
stands for 97.5% quantile.
from Angara
Full name: Tutorial.distribution
Full name: Tutorial.generator
type MT19937 =
new : copy:MT19937 -> MT19937
new : seed:uint32 [] -> MT19937
new : ?seed:uint32 -> MT19937
private new : mt:uint32 [] * idx:int -> MT19937
member bernoulli : p:float -> bool
member private getIdx : int
member private getMt : uint32 []
member get_seed : unit -> uint32 []
member normal : unit -> float
member uniform_float64 : unit -> float
...
Full name: Angara.Statistics.MT19937
--------------------
new : ?seed:uint32 -> MT19937
new : seed:uint32 [] -> MT19937
new : copy:MT19937 -> MT19937
Full name: Tutorial.random_values
Full name: Tutorial.seed
Full name: Tutorial.g'
Full name: Tutorial.g''
Full name: Tutorial.test_3
Full name: Tutorial.samples
Full name: Angara.Statistics.draw
Full name: Tutorial.sampling_density_x
Full name: Tutorial.sampling_density_y
Full name: Angara.Statistics.kde
Full name: Tutorial.analytic_density_y
Full name: Microsoft.FSharp.Core.Operators.exp
Full name: Angara.Statistics.log_pdf
Full name: Tutorial.chart
{Plots: PlotInfo list;}
static member ofList : plots:PlotInfo list -> Chart
Full name: Angara.Charting.Chart
private new : unit -> Plot
static member band : seriesX:float [] * seriesY1:float [] * seriesY2:float [] * ?fill:string * ?displayName:string * ?titles:BandTitles -> PlotInfo
static member heatmap : x:float [] * y:float [] * values:float [] * ?colorPalette:string * ?treatAs:HeatmapTreatAs * ?displayName:string * ?titles:HeatmapTitles -> PlotInfo
static member heatmap : x:float [] * y:float [] * values:HeatmapValues * ?colorPalette:string * ?treatAs:HeatmapTreatAs * ?displayName:string * ?titles:HeatmapTitles -> PlotInfo
static member line : seriesY:float [] * ?stroke:string * ?thickness:float * ?treatAs:LineTreatAs * ?fill68:string * ?fill95:string * ?displayName:string * ?titles:LineTitles -> PlotInfo
static member line : seriesX:float [] * seriesY:float [] * ?stroke:string * ?thickness:float * ?treatAs:LineTreatAs * ?fill68:string * ?fill95:string * ?displayName:string * ?titles:LineTitles -> PlotInfo
static member line : x:LineX * y:LineY * ?stroke:string * ?thickness:float * ?treatAs:LineTreatAs * ?fill68:string * ?fill95:string * ?displayName:string * ?titles:LineTitles -> PlotInfo
static member markers : seriesX:float [] * seriesY:float [] * ?color:MarkersColor * ?colorPalette:string * ?size:MarkersSize * ?sizeRange:MarkersSizeRange * ?shape:MarkersShape * ?borderColor:string * ?displayName:string * ?titles:MarkersTitles -> PlotInfo
static member markers : x:MarkersX * y:MarkersY * ?color:MarkersColor * ?colorPalette:string * ?size:MarkersSize * ?sizeRange:MarkersSizeRange * ?shape:MarkersShape * ?borderColor:string * ?displayName:string * ?titles:MarkersTitles -> PlotInfo
Full name: Angara.Charting.Plot
static member Plot.line : seriesX:float [] * seriesY:float [] * ?stroke:string * ?thickness:float * ?treatAs:LineTreatAs * ?fill68:string * ?fill95:string * ?displayName:string * ?titles:LineTitles -> PlotInfo
static member Plot.line : x:LineX * y:LineY * ?stroke:string * ?thickness:float * ?treatAs:LineTreatAs * ?fill68:string * ?fill95:string * ?displayName:string * ?titles:LineTitles -> PlotInfo
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Full name: Angara.Statistics.summary
Full name: Angara.Statistics.qsummary