6.3 KiB
sidebar_position | title |
---|---|
2 | Distribution |
mixture
Definition
mixture(...distributions, weights:list<float>):distribution
Examples
mixture(normal(5,1), normal(10,1))
sample
Get one random sample from the distribution
Definition
sample(distribution):number
Examples
sample(normal(5,2))
sampleN
Get n random samples from the distribution
Definition
sample(distribution, number):list<number>
Examples
sample(normal(5,2), 100)
mean
Get the distribution mean
Definition
mean(distribution):number
Examples
mean(normal(5,2))
cdf
Definition
cdf(distribution, number):number
Examples
cdf(normal(5,2), 3)
Definition
pdf(distribution, number):number
Examples
pdf(normal(5,2), 3)
inv
Definition
inv(distribution, number):number
Examples
inv(normal(5,2), 0.5)
toPointSet
Converts a distribution to the pointSet format
Definition
toPointSet(distribution):pointSetDistribution
Examples
toPointSet(normal(5,2))
toSampleSet
Converts a distribution to the sampleSet format, with n samples
Definition
toSampleSet(distribution,n):sampleSetDistribution
Examples
toSampleSet(normal(5,2))
truncateLeft
Truncates the left side of a distribution. Returns either a pointSet distribution or a symbolic distribution.
Definition
truncateLeft(distribution, l:number):distribution
Examples
truncateLeft(normal(5,2), 3)
truncateRight
Truncates the right side of a distribution. Returns either a pointSet distribution or a symbolic distribution.
Definition
truncateRight(distribution, r:number):distribution
Examples
truncateLeft(normal(5,2), 6)
klDivergence
Kullback–Leibler divergence between two distributions
Definition
klDivergence(distribution, distribution):number
Examples
klDivergence(normal(5,2), normal(5,4)) // returns 0.57
logScoreWithPointAnswer
Definition
logScoreWithPointAnswer(distribution, number):number
Examples
logScoreWithPointAnswer(normal(5,2), 3) // returns 2.11
toString
Definition
toString(distribution):string
Examples
toString(normal(5,2))
toSparkline
Produce a sparkline of length n
Definition
toSparkline(distribution, n=20):string
Examples
toSparkline(normal(5,2), 10):string
inspect
Prints the value of the distribution to the Javascript console, then returns the distribution.
Definition
inspect(distribution):distribution
Examples
inspect(normal(5,2))
normalize
Normalize a distribution. This means scaling it appropriately so that it's cumulative sum is equal to 1.
Definition
normalize(distribution):distribution
Examples
normalize(normal(5,2))
isNormalized
Check of a distribution is normalized. Most distributions are typically normalized, but there are some commands that could produce non-normalized distributions.
Definition
isNormalized(distribution):bool
Examples
isNormalized(normal(5,2)) // returns true
integralSum
Get the sum of the integral of a distribution. If the distribution is normalized, this will be 1.
Definition
integralSum(distribution):number
Examples
integralSum(normal(5,2))
log
Definition
log(distribution):distribution
log10
Definition
log10(distribution):distribution
unaryMinus
Definition
unaryMinus(distribution):distribution
add
Definition
dotSubtract(distribution, distribution): distribution
multiply
Definition
dotSubtract(distribution, distribution): distribution
subtract
Definition
dotSubtract(distribution, distribution): distribution
divide
Definition
dotSubtract(distribution, distribution): distribution
pow
Definition
dotSubtract(distribution, distribution): distribution
dotAdd
Definition
dotSubtract(distribution, distribution): distribution
dotMultiply
Definition
dotSubtract(distribution, distribution): distribution
dotSubtract
Definition
dotSubtract(distribution, distribution): distribution
dotDivide
Definition
dotSubtract(distribution, distribution): distribution
dotPow
Definition
dotSubtract(distribution, distribution): distribution
dotExp
Definition
dotSubtract(distribution, distribution): distribution
scaleLog
Definition
scaleLog(distribution): distribution
scaleLog10
Definition
dotSubtract(distribution, distribution): distribution
scaleLogWithThreshold
Definition
dotSubtract(distribution, distribution): distribution
scalePow
Definition
dotSubtract(distribution, distribution): distribution
scaleExp
Definition
dotSubtract(distribution, distribution): distribution
toInternalSampleArray
Gets the internal samples of a sampleSet distribution. This is separate from the sampleN() function, which would shuffle the samples. toInternalSampleArray() maintains order and length.
Definition
toInternalSampleArray(sampleSetDist):list<number>
Examples
toInternalSampleArray(toSampleSet(normal(5,2)))
mapSamples
Definition
dotSubtract(distribution, distribution): distribution
mapSamples2
Definition
dotSubtract(distribution, distribution): distribution
mapSamples3
Definition
dotSubtract(distribution, distribution): distribution