Header menu logo FSharp.Stats

Array Module

Module to compute common statistical measure on array

Functions and values

Function or value Description

Array.cov array1 array2

Full Usage: Array.cov array1 array2

Parameters:
    array1 : ^T array - The first input array.
    array2 : ^T array - The second input array.

Returns: ^U sample covariance estimator (Bessel's correction by N-1)
Modifiers: inline
Type parameters: ^T, ^U, ^a

Computes the sample covariance of two random variables

Returns NaN if data is empty or if any entry is NaN.

array1 : ^T array

The first input array.

array2 : ^T array

The second input array.

Returns: ^U

sample covariance estimator (Bessel's correction by N-1)

Array.covBy f array

Full Usage: Array.covBy f array

Parameters:
    f : 'T -> ^a * ^a - A function applied to transform each element of the input array into a tuple of paired observations.
    array : 'T array - The input array.

Returns: ^U sample covariance estimator (Bessel's correction by N-1)
Modifiers: inline
Type parameters: 'T, ^a, ^U, ^b

Computes the sample covariance of two random variables generated by applying a function to the input array.

Returns NaN if data is empty or if any entry is NaN.

f : 'T -> ^a * ^a

A function applied to transform each element of the input array into a tuple of paired observations.

array : 'T array

The input array.

Returns: ^U

sample covariance estimator (Bessel's correction by N-1)

Example

 
 // To get the sample covariance between x and y observations:
 let xy = [| {| x = 5.; y = 2. |}
             {| x = 12.; y = 8. |}
             {| x = 18.; y = 18. |}
             {| x = -23.; y = -20. |} 
             {| x = 45.; y = 28. |} |]
 
 xy |> Array.covBy (fun x -> x.x, x.y) // evaluates to 434.90
val xy: {| x: float; y: float |} array
anonymous record field x: float
anonymous record field y: float
module Array from Microsoft.FSharp.Collections

Array.covOfPairs array

Full Usage: Array.covOfPairs array

Parameters:
    array : (^T * ^T) array - The input array.

Returns: ^U sample covariance estimator (Bessel's correction by N-1)
Modifiers: inline
Type parameters: ^T, ^U, ^a

Computes the sample covariance of two random variables. The covariance will be calculated between the paired observations.

Returns NaN if data is empty or if any entry is NaN.

array : (^T * ^T) array

The input array.

Returns: ^U

sample covariance estimator (Bessel's correction by N-1)

Example

 
 // Consider an array of paired x and y values:
 // [| (x1, y1); (x2, y2); (x3, y3); (x4, y4); ... |]
 let xy = [| (5., 2.); (12., 8.); (18., 18.); (-23., -20.); (45., 28.) |]
 
 // To get the sample covariance between x and y:
 xy |> Array.covOfPairs // evaluates to 434.90
val xy: (float * float) array
module Array from Microsoft.FSharp.Collections

Array.covPopulation array1 array2

Full Usage: Array.covPopulation array1 array2

Parameters:
    array1 : ^T array - The first input array.
    array2 : ^T array - The second input array.

Returns: ^U population covariance estimator (denominator N)
Modifiers: inline
Type parameters: ^T, ^U, ^a

Computes the population covariance of two random variables

Returns NaN if data is empty or if any entry is NaN.

array1 : ^T array

The first input array.

array2 : ^T array

The second input array.

Returns: ^U

population covariance estimator (denominator N)

Array.covPopulationBy f array

Full Usage: Array.covPopulationBy f array

Parameters:
    f : 'T -> ^a * ^a - A function applied to transform each element of the input array into a tuple of paired observations.
    array : 'T array - The input array.

Returns: ^U population covariance estimator (denominator N)
Modifiers: inline
Type parameters: 'T, ^a, ^U, ^b

Computes the population covariance of two random variables generated by applying a function to the input array.

Returns NaN if data is empty or if any entry is NaN.

f : 'T -> ^a * ^a

A function applied to transform each element of the input array into a tuple of paired observations.

array : 'T array

The input array.

Returns: ^U

population covariance estimator (denominator N)

Example

 
 // To get the population covariance between x and y observations:
 let xy = [| {| x = 5.; y = 2. |}
             {| x = 12.; y = 8. |}
             {| x = 18.; y = 18. |}
             {| x = -23.; y = -20. |} 
             {| x = 45.; y = 28. |} |]
 
 xy |> Array.covPopulationBy (fun x -> x.x, x.y) // evaluates to 347.92
val xy: {| x: float; y: float |} array
anonymous record field x: float
anonymous record field y: float
module Array from Microsoft.FSharp.Collections

Array.covPopulationOfPairs array

Full Usage: Array.covPopulationOfPairs array

Parameters:
    array : (^T * ^T) array - The input array.

Returns: ^U population covariance estimator (denominator N)
Modifiers: inline
Type parameters: ^T, ^U, ^a

Computes the population covariance of two random variables. The covariance will be calculated between the paired observations.

Returns NaN if data is empty or if any entry is NaN.

array : (^T * ^T) array

The input array.

Returns: ^U

population covariance estimator (denominator N)

Example

 
 // Consider an array of paired x and y values:
 // [| (x1, y1); (x2, y2); (x3, y3); (x4, y4); ... |]
 let xy = [| (5., 2.); (12., 8.); (18., 18.); (-23., -20.); (45., 28.) |]
 
 // To get the population covariance between x and y:
 xy |> Array.covPopulationOfPairs // evaluates to 347.92
val xy: (float * float) array
module Array from Microsoft.FSharp.Collections

Array.dropNaN array

Full Usage: Array.dropNaN array

Parameters:
    array : float array -

Returns: float array

Filters out all nan values from an array

array : float array

Returns: float array

Example

Array.median items

Full Usage: Array.median items

Parameters:
    items : ^T array -

Returns: ^T
Modifiers: inline
Type parameters: ^T, ^a

Computes the sample median

items : ^T array

Returns: ^T

Example

Array.medianAbsoluteDev data

Full Usage: Array.medianAbsoluteDev data

Parameters:
    data : float[] -

Returns: float

Median absolute deviation (MAD)

data : float[]

Returns: float

Example

Array.partitionSortInPlace left right items

Full Usage: Array.partitionSortInPlace left right items

Parameters:
    left : int -
    right : int -
    items : 'T array -

Returns: int
Modifiers: inline
Type parameters: 'T

Arranges the items between the left and right border, that all items left of the pivot element are smaller and bigger on the right.
Function works in place and returns the index of the pivote element (using Lomuto's partitioning algorithm)

left : int

right : int

items : 'T array

Returns: int

Example

Array.quickSelect k items

Full Usage: Array.quickSelect k items

Parameters:
    k : int -
    items : 'T array -

Returns: 'T
Modifiers: inline
Type parameters: 'T

Finds the kth smallest element in an unordered array (note that k is ONE-based)

k : int

items : 'T array

Returns: 'T

Example

Array.quickSelectInPlace k items

Full Usage: Array.quickSelectInPlace k items

Parameters:
    k : int -
    items : 'T array -

Returns: 'T
Modifiers: inline
Type parameters: 'T

Finds the kth smallest element in an unordered array (note that k is ONE-based)
Works in place and can change the order of the elements in the input array

k : int

items : 'T array

Returns: 'T

Example

Array.quickSelectInPlaceWith left right k arr

Full Usage: Array.quickSelectInPlaceWith left right k arr

Parameters:
    left : int -
    right : int -
    k : int -
    arr : 'T array -

Returns: 'T
Modifiers: inline
Type parameters: 'T

Finds the kth smallest element in an unordered array (note that k is ONE-based)
Works in place and can change the order of the elements in the input array

left : int

right : int

k : int

arr : 'T array

Returns: 'T

Example

Array.range a

Full Usage: Array.range a

Parameters:
    a : 'a array

Returns: Interval<'a>
a : 'a array
Returns: Interval<'a>

Array.sampleWithOutReplacement rnd source k

Full Usage: Array.sampleWithOutReplacement rnd source k

Parameters:
    rnd : Random -
    source : 'a array -
    k : int -

Returns: 'a array

Samples from an array of obj without replacement (without putting back)

Implementation according to: http://krkadev.blogspot.de/2010/08/random-numbers-without-repetition.html

rnd : Random

source : 'a array

k : int

Returns: 'a array

Example

Array.sampleWithReplacement rnd source k

Full Usage: Array.sampleWithReplacement rnd source k

Parameters:
    rnd : Random -
    source : 'a array -
    k : int -

Returns: 'a array

Samples from an array of obj wit replacement (with putting back)

When we sample with replacement, the two sample values are independent.Practically, this means that what we get on the first one doesn't affect what we get on the second.Mathematically, this means that the covariance between the two is zero

rnd : Random

source : 'a array

k : int

Returns: 'a array

Example

Array.seqInit from tto length

Full Usage: Array.seqInit from tto length

Parameters:
    from : float -
    tto : float -
    length : int -

Returns: float array

Generates array sequence (like R! seq.int)

from : float

tto : float

length : int

Returns: float array

Example

Array.shuffleFisherYates arr

Full Usage: Array.shuffleFisherYates arr

Parameters:
    arr : 'a[] -

Returns: 'a array

Shuffels the input array (method: Fisher-Yates)

arr : 'a[]

Returns: 'a array

Example

Array.shuffleFisherYatesInPlace arr

Full Usage: Array.shuffleFisherYatesInPlace arr

Parameters:
    arr : 'a[] -

Returns: 'a[]

Shuffels the input array (method: Fisher-Yates) in place

arr : 'a[]

Returns: 'a[]

Example

Array.sort2InPlaceByKeys from count keys items

Full Usage: Array.sort2InPlaceByKeys from count keys items

Parameters:
    from : int
    count : int
    keys : 'T array
    items : 'T array

from : int
count : int
keys : 'T array
items : 'T array

Array.swapInPlace left right items

Full Usage: Array.swapInPlace left right items

Parameters:
    left : int
    right : int
    items : 'T array

Modifiers: inline
Type parameters: 'T
left : int
right : int
items : 'T array

Array.varOf mean items

Full Usage: Array.varOf mean items

Parameters:
    mean : ^a -
    items : ^T[] -

Returns: ^T
Modifiers: inline
Type parameters: ^a, ^T, ^b, ^c, ^d

Computes the Variance N-1

mean : ^a

items : ^T[]

Returns: ^T

Example

Array.weightedMean weights items

Full Usage: Array.weightedMean weights items

Parameters:
    weights : ^T array -
    items : ^T array -

Returns: 'b
Modifiers: inline
Type parameters: ^T, ^a, 'b

Computes the Weighted Mean

weights : ^T array

items : ^T array

Returns: 'b

Example

Array.weightedVariance mean weights items

Full Usage: Array.weightedVariance mean weights items

Parameters:
    mean : ^a -
    weights : ^T array -
    items : ^T array -

Returns: 'f
Modifiers: inline
Type parameters: ^a, ^T, ^b, ^c, ^d, ^e, 'f

Computes the Weighted Variance

mean : ^a

weights : ^T array

items : ^T array

Returns: 'f

Example

Type something to start searching.