Lots of simple cleanup to api docs
This commit is contained in:
parent
590480d4e1
commit
6dc8b711bb
|
@ -18,7 +18,7 @@ describe("builtin", () => {
|
|||
testEval("2>1", "Ok(true)")
|
||||
testEval("concat('a','b')", "Ok('ab')")
|
||||
testEval(
|
||||
"addOne(t)=t+1; toInternalSampleArray(mapSamples(fromSamples([1,2,3,4,5,6]), addOne))",
|
||||
"addOne(t)=t+1; toList(mapSamples(fromSamples([1,2,3,4,5,6]), addOne))",
|
||||
"Ok([2,3,4,5,6,7])",
|
||||
)
|
||||
})
|
||||
|
|
|
@ -27,6 +27,8 @@ let dispatch = (call: EV.functionCall, _: DistributionOperation.env): option<
|
|||
EV.EvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some
|
||||
| ("divide", [EvTimeDuration(d1), EvNumber(d2)]) =>
|
||||
EV.EvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some
|
||||
| ("divide", [EvTimeDuration(d1), EvTimeDuration(d2)]) =>
|
||||
EV.EvNumber(d1 /. d2)->Ok->Some
|
||||
| _ => None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ let dispatchToGenericOutput = (
|
|||
Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist, ~env)
|
||||
| ("toSampleSet", [EvDistribution(dist)]) =>
|
||||
Helpers.toDistFn(ToSampleSet(env.sampleCount), dist, ~env)
|
||||
| ("toInternalSampleArray", [EvDistribution(SampleSet(dist))]) =>
|
||||
| ("toList", [EvDistribution(SampleSet(dist))]) =>
|
||||
Some(FloatArray(SampleSetDist.T.get(dist)))
|
||||
| ("fromSamples", [EvArray(inputArray)]) => {
|
||||
let _wrapInputErrors = x => SampleSetDist.NonNumericInput(x)
|
||||
|
|
42
packages/website/docs/Api/Date.md
Normal file
42
packages/website/docs/Api/Date.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
title: Date
|
||||
---
|
||||
|
||||
### makeFromYear
|
||||
|
||||
```
|
||||
Date.makeFromYear: (number) => date
|
||||
```
|
||||
|
||||
```js
|
||||
makeFromYear(2022.32);
|
||||
```
|
||||
|
||||
### toString
|
||||
|
||||
```
|
||||
toString: (date) => string
|
||||
```
|
||||
|
||||
### subtract
|
||||
|
||||
```
|
||||
subtract: (date, date) => duration
|
||||
subtract: (date, duration) => date
|
||||
```
|
||||
|
||||
```js
|
||||
makeFromYear(2040) - makeFromYear(2020) // 20 years
|
||||
makeFromYear(2040) - years(20) // 2020
|
||||
```
|
||||
|
||||
### add
|
||||
|
||||
```
|
||||
add: (date, duration) => date
|
||||
```
|
||||
|
||||
```js
|
||||
makeFromYear(2022.32) + years(5);
|
||||
```
|
|
@ -1,58 +1,58 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
sidebar_position: 2
|
||||
title: Dictionary
|
||||
---
|
||||
|
||||
### toString
|
||||
### toList
|
||||
```
|
||||
toString: (dict<'a>) => string
|
||||
Dict.toList: (dict<'a>) => list<list<string|a>>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### get
|
||||
```
|
||||
Dict.get: (dict<'a>, string) => a
|
||||
```js
|
||||
Dict.toList({foo: 3, bar: 20}) // [["foo", 3], ["bar", 20]]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### set
|
||||
### fromList
|
||||
```
|
||||
Dict.set: (dict<'a>, string, a) => a
|
||||
Dict.fromList: (list<list<string|'a>>) => dict<'a>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toPairs
|
||||
```js
|
||||
Dict.fromList([["foo", 3], ["bar", 20]]) // {foo: 3, bar: 20}
|
||||
```
|
||||
Dict.toPairs: (dict<'a>) => list<list<string|a>>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### keys
|
||||
```
|
||||
Dict.keys: (dict<'a>) => list<string>
|
||||
```
|
||||
|
||||
|
||||
```js
|
||||
Dict.keys({foo: 3, bar: 20}) // ["foo", "bar"]
|
||||
```
|
||||
|
||||
### values
|
||||
```
|
||||
Dict.values: (dict<'a>) => list<'a>
|
||||
```
|
||||
|
||||
|
||||
```js
|
||||
Dict.values({foo: 3, bar: 20}) // [3,20]
|
||||
```
|
||||
|
||||
### merge
|
||||
```
|
||||
Dict.merge: (dict<'a>, dict<'b>) => dict<'a|b>
|
||||
```
|
||||
|
||||
|
||||
```js
|
||||
first = {a: 1, b: 2}
|
||||
snd = {b: 3, c: 5}
|
||||
Dict.merge(first, snd) // {a: 1, b: 3, c: 5}
|
||||
```
|
||||
|
||||
### mergeMany
|
||||
```
|
||||
Dict.mergeMany: (list<dict<'a>>) => dict<'a>
|
||||
```
|
||||
|
||||
```js
|
||||
first = {a: 1, b: 2}
|
||||
snd = {b: 3, c: 5}
|
||||
Dict.mergeMany([first, snd]) // {a: 1, b: 3, c: 5}
|
||||
```
|
|
@ -1,32 +1,33 @@
|
|||
---
|
||||
sidebar_position: 2
|
||||
sidebar_position: 3
|
||||
title: Distribution
|
||||
---
|
||||
import TOCInline from '@theme/TOCInline';
|
||||
|
||||
import TOCInline from "@theme/TOCInline";
|
||||
|
||||
<TOCInline toc={toc} />
|
||||
|
||||
## Creation
|
||||
## Distribution Creation
|
||||
|
||||
### Normal Distribution
|
||||
|
||||
**Definitions**
|
||||
|
||||
```javascript
|
||||
normal(frValueDistOrNumber, frValueDistOrNumber);
|
||||
normal: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
```javascript
|
||||
normal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
||||
normal: (dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
||||
```
|
||||
|
||||
```javascript
|
||||
normal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
||||
normal: (dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
```js
|
||||
normal(5, 1);
|
||||
normal({ p5: 4, p95: 10 });
|
||||
normal({ mean: 5, stdev: 2 });
|
||||
|
@ -37,15 +38,15 @@ normal({ mean: 5, stdev: 2 });
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
lognormal(frValueDistOrNumber, frValueDistOrNumber);
|
||||
lognormal: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
```javascript
|
||||
lognormal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
||||
lognormal: (dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
||||
```
|
||||
|
||||
```javascript
|
||||
lognormal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
||||
lognormal: (dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -61,7 +62,7 @@ lognormal({ mean: 5, stdev: 2 });
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
uniform(frValueDistOrNumber, frValueDistOrNumber);
|
||||
uniform: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -75,7 +76,7 @@ uniform(10, 12);
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
beta(frValueDistOrNumber, frValueDistOrNumber);
|
||||
beta: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -89,7 +90,7 @@ beta(20, 25);
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
cauchy(frValueDistOrNumber, frValueDistOrNumber);
|
||||
cauchy: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -103,7 +104,7 @@ cauchy(5, 1);
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
gamma(frValueDistOrNumber, frValueDistOrNumber);
|
||||
gamma: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -117,7 +118,7 @@ gamma(5, 1);
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
logistic(frValueDistOrNumber, frValueDistOrNumber);
|
||||
logistic: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -131,7 +132,7 @@ gamma(5, 1);
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
to(frValueDistOrNumber, frValueDistOrNumber);
|
||||
to: (frValueDistOrNumber, frValueDistOrNumber);
|
||||
```
|
||||
|
||||
```javascript
|
||||
|
@ -151,7 +152,7 @@ to(5,10)
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
exponential(frValueDistOrNumber);
|
||||
exponential: (frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -165,7 +166,7 @@ exponential(2);
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
bernoulli(frValueDistOrNumber);
|
||||
bernoulli: (frValueDistOrNumber);
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -181,7 +182,7 @@ Converts a set of points to a continuous distribution
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
toContinuousPointSet(array<dict<{x: numeric, y: numeric}>>)
|
||||
toContinuousPointSet: (array<dict<{x: numeric, y: numeric}>>)
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -202,7 +203,7 @@ Converts a set of points to a discrete distribution
|
|||
**Definitions**
|
||||
|
||||
```javascript
|
||||
toDiscretePointSet(array<dict<{x: numeric, y: numeric}>>)
|
||||
toDiscretePointSet: (array<dict<{x: numeric, y: numeric}>>)
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -216,41 +217,19 @@ toDiscretePointSet([
|
|||
]);
|
||||
```
|
||||
|
||||
### Declaration (Continuous Function)
|
||||
|
||||
Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making predictions. It allows you to limit the domain that your prediction will be used and scored within.
|
||||
|
||||
**Definitions**
|
||||
|
||||
```javascript
|
||||
declareFn(dict<{fn: lambda, inputs: array<dict<{min: number, max: number}>>}>)
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
declareFn({
|
||||
fn: {|a,b| a },
|
||||
inputs: [
|
||||
{min: 0, max: 100},
|
||||
{min: 30, max: 50}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
|
||||
### mixture
|
||||
|
||||
```javascript
|
||||
(...distributionLike, weights:list<float>):distribution
|
||||
mixture: (...distributionLike, weights:list<float>):distribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
mixture(normal(5, 1), normal(10, 1));
|
||||
mx(normal(5, 1), normal(10, 1), [0.3, 0.7]);
|
||||
```
|
||||
|
||||
### sample
|
||||
|
@ -258,7 +237,7 @@ mixture(normal(5, 1), normal(10, 1));
|
|||
Get one random sample from the distribution
|
||||
|
||||
```javascript
|
||||
(distribution):number
|
||||
sample(distribution):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -272,13 +251,13 @@ sample(normal(5, 2));
|
|||
Get n random samples from the distribution
|
||||
|
||||
```javascript
|
||||
(distribution, number):list<number>
|
||||
sampleN: (distribution, number):list<number>
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
sample(normal(5, 2), 100);
|
||||
sample: (normal(5, 2), 100);
|
||||
```
|
||||
|
||||
### mean
|
||||
|
@ -286,73 +265,61 @@ sample(normal(5, 2), 100);
|
|||
Get the distribution mean
|
||||
|
||||
```javascript
|
||||
(distribution):number
|
||||
mean: (distribution):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
mean(normal(5, 2));
|
||||
mean: (normal(5, 2));
|
||||
```
|
||||
|
||||
### stdev
|
||||
|
||||
```javascript
|
||||
(distribution):number
|
||||
stdev: (distribution):number
|
||||
```
|
||||
|
||||
### variance
|
||||
|
||||
```javascript
|
||||
(distribution):number
|
||||
variance: (distribution):number
|
||||
```
|
||||
|
||||
### mode
|
||||
|
||||
```javascript
|
||||
(distribution):number
|
||||
mode: (distribution):number
|
||||
```
|
||||
|
||||
### cdf
|
||||
|
||||
```javascript
|
||||
(distribution, number):number
|
||||
cdf: (distribution, number):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
cdf(normal(5, 2), 3);
|
||||
cdf: (normal(5, 2), 3);
|
||||
```
|
||||
|
||||
### pdf
|
||||
|
||||
```javascript
|
||||
(distribution, number):number
|
||||
pdf: (distribution, number):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
pdf(normal(5, 2), 3);
|
||||
```
|
||||
|
||||
### pmf
|
||||
|
||||
```javascript
|
||||
(distribution, number):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
pmf(bernoulli(0.3), 0); // 0.7
|
||||
pdf: (normal(5, 2), 3);
|
||||
```
|
||||
|
||||
### inv
|
||||
|
||||
```javascript
|
||||
(distribution, number):number
|
||||
inv: (distribution, number):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -366,7 +333,7 @@ inv(normal(5, 2), 0.5);
|
|||
Converts a distribution to the pointSet format
|
||||
|
||||
```javascript
|
||||
(distribution):pointSetDistribution
|
||||
toPointSet: (distribution):pointSetDistribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -380,13 +347,13 @@ toPointSet(normal(5, 2));
|
|||
Converts a distribution to the sampleSet format, with n samples
|
||||
|
||||
```javascript
|
||||
(distribution,n):sampleSetribution
|
||||
toSampleSet: (distribution,number):sampleSetDistribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
toSampleSet(normal(5, 2));
|
||||
toSampleSet(normal(5, 2), 1000);
|
||||
```
|
||||
|
||||
### truncateLeft
|
||||
|
@ -394,7 +361,7 @@ toSampleSet(normal(5, 2));
|
|||
Truncates the left side of a distribution. Returns either a pointSet distribution or a symbolic distribution.
|
||||
|
||||
```javascript
|
||||
(distribution, l:number, {normalize: boolean=true}):distribution
|
||||
truncateLeft: (distribution, l:number):distribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -408,7 +375,7 @@ truncateLeft(normal(5, 2), 3);
|
|||
Truncates the right side of a distribution. Returns either a pointSet distribution or a symbolic distribution.
|
||||
|
||||
```javascript
|
||||
(distribution, r:number, {normalize: boolean=true}):distribution
|
||||
truncateRight: (distribution, r:number):distribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -424,7 +391,7 @@ truncateLeft(normal(5, 2), 6);
|
|||
Kullback–Leibler divergence between two distributions
|
||||
|
||||
```javascript
|
||||
(distribution, distribution):number
|
||||
klDivergence: (distribution, distribution):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -433,24 +400,12 @@ Kullback–Leibler divergence between two distributions
|
|||
klDivergence(normal(5, 2), normal(5, 4)); // returns 0.57
|
||||
```
|
||||
|
||||
### logScore
|
||||
|
||||
```javascript
|
||||
({estimate: distribution, prior?: distribution, answer: distribution|number}):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
logScore({ estimate: normal(5, 2), prior: normal(5.5, 4), answer: 2.3 });
|
||||
```
|
||||
|
||||
## Display
|
||||
|
||||
### toString
|
||||
|
||||
```javascript
|
||||
(distribution):string
|
||||
: (distribution):string
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -464,7 +419,7 @@ toString(normal(5, 2));
|
|||
Produce a sparkline of length n
|
||||
|
||||
```javascript
|
||||
(distribution, n=20):string
|
||||
toSparkline: (distribution, n=20):string
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -478,7 +433,7 @@ toSparkline(normal(5, 2), 10);
|
|||
Prints the value of the distribution to the Javascript console, then returns the distribution.
|
||||
|
||||
```javascript
|
||||
(distribution):distribution
|
||||
inspect: (distribution):distribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -494,7 +449,7 @@ inspect(normal(5, 2));
|
|||
Normalize a distribution. This means scaling it appropriately so that it's cumulative sum is equal to 1.
|
||||
|
||||
```javascript
|
||||
(distribution):distribution
|
||||
normalize: (distribution):distribution
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -508,7 +463,7 @@ normalize(normal(5, 2));
|
|||
Check of a distribution is normalized. Most distributions are typically normalized, but there are some commands that could produce non-normalized distributions.
|
||||
|
||||
```javascript
|
||||
(distribution):bool
|
||||
isNormalized: (distribution):bool
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -522,7 +477,7 @@ isNormalized(normal(5, 2)); // returns true
|
|||
Get the sum of the integral of a distribution. If the distribution is normalized, this will be 1.
|
||||
|
||||
```javascript
|
||||
(distribution):number
|
||||
integralSum: (distribution):number
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
@ -531,158 +486,162 @@ Get the sum of the integral of a distribution. If the distribution is normalized
|
|||
integralSum(normal(5, 2));
|
||||
```
|
||||
|
||||
## Algebra1
|
||||
## Algebraic Operations
|
||||
|
||||
### add
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
add: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### sum
|
||||
|
||||
```javascript
|
||||
(list<distributionLike>): distribution
|
||||
sum: (list<distributionLike>): distribution
|
||||
```
|
||||
|
||||
### multiply
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
multiply: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### product
|
||||
|
||||
```javascript
|
||||
(list<distributionLike>): distribution
|
||||
product: (list<distributionLike>): distribution
|
||||
```
|
||||
|
||||
### subtract
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
subtract: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### divide
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
divide: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### pow
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
pow: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### exp
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
exp: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### log
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
log: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### log10
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike):distribution
|
||||
log10: (distributionLike, distributionLike):distribution
|
||||
```
|
||||
|
||||
### unaryMinus
|
||||
|
||||
```javascript
|
||||
(distribution):distribution
|
||||
unaryMinus: (distribution):distribution
|
||||
```
|
||||
|
||||
## Algebra2
|
||||
## Pointwise Operations
|
||||
|
||||
### dotAdd
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotSum
|
||||
|
||||
```javascript
|
||||
(list<distributionLike>): distribution
|
||||
dotAdd: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotMultiply
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotProduct
|
||||
|
||||
```javascript
|
||||
(list<distributionLike>): distribution
|
||||
dotMultiply: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotSubtract
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
dotSubtract: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotDivide
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
dotDivide: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotPow
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
dotPow: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
### dotExp
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
dotExp: (distributionLike, distributionLike): distribution
|
||||
```
|
||||
|
||||
## Algebra3
|
||||
## Scale Operations
|
||||
|
||||
### scaleMultiply
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
scaleMultiply: (distributionLike, number): distribution
|
||||
```
|
||||
|
||||
### scalePow
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
scalePow: (distributionLike, number): distribution
|
||||
```
|
||||
|
||||
### scaleExp
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
scaleExp: (distributionLike, number): distribution
|
||||
```
|
||||
|
||||
### scaleLog
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
scaleLog: (distributionLike, number): distribution
|
||||
```
|
||||
|
||||
### scaleLog10
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike): distribution
|
||||
scaleLog10: (distributionLike, number): distribution
|
||||
```
|
||||
|
||||
### scaleLogWithThreshold
|
||||
## Special
|
||||
|
||||
### Declaration (Continuous Function)
|
||||
|
||||
Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making predictions. It allows you to limit the domain that your prediction will be used and scored within.
|
||||
|
||||
```javascript
|
||||
(distributionLike, distributionLike, number): distribution
|
||||
declareFn: (dict<{fn: lambda, inputs: array<dict<{min: number, max: number}>>}>)
|
||||
```
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
declareFn({
|
||||
fn: {|a,b| a },
|
||||
inputs: [
|
||||
{min: 0, max: 100},
|
||||
{min: 30, max: 50}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
sidebar_position: 3
|
||||
sidebar_position: 4
|
||||
title: Point Set Distribution
|
||||
---
|
||||
|
||||
|
@ -8,23 +8,12 @@ title: Point Set Distribution
|
|||
PointSet.make: (distribution) => pointSetDist
|
||||
```
|
||||
|
||||
|
||||
|
||||
### makeContinuous
|
||||
```
|
||||
PointSet.makeContinuous: (list<{x: number, y: number}>) => pointSetDist
|
||||
```
|
||||
|
||||
|
||||
|
||||
### makeDiscrete
|
||||
```
|
||||
PointSet.makeDiscrete: (list<{x: number, y: number}>) => pointSetDist
|
||||
```
|
||||
|
||||
|
||||
|
||||
### mapPoints
|
||||
```
|
||||
PointSet.mapPoints: (pointSetDist, ({x:number, y:number} => {x:number, y:number})) => pointSetDist
|
||||
```
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
sidebar_position: 4
|
||||
sidebar_position: 5
|
||||
title: Sample Set Distribution
|
||||
---
|
||||
|
||||
|
@ -10,58 +10,31 @@ SampleSet.make: (() => number) => sampleSet
|
|||
SampleSet.make: (list<number>) => sampleSet
|
||||
```
|
||||
|
||||
|
||||
|
||||
### kde
|
||||
```
|
||||
SampleSet.kde: (sampleSet) => pointSetDist
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toEmpiricalPdf
|
||||
```
|
||||
SampleSet.toEmpiricalPdf: (sampleSet) => pointSetDist
|
||||
```
|
||||
|
||||
|
||||
|
||||
### map
|
||||
```
|
||||
SampleSet.map: (sampleSet, (number => number)) => sampleSet
|
||||
```
|
||||
|
||||
|
||||
|
||||
### map2
|
||||
```
|
||||
SampleSet.map2: (sampleSet, sampleSet, ((number, number) => number)) => sampleSet
|
||||
```
|
||||
|
||||
|
||||
|
||||
### map3
|
||||
```
|
||||
SampleSet.map3: (sampleSet, sampleSet, sampleSet, ((number, number, number) => number)) => sampleSet
|
||||
```
|
||||
|
||||
|
||||
|
||||
### correlation
|
||||
### toList
|
||||
```
|
||||
SampleSet.correlation: (sampleSet, sampleSet) => number
|
||||
SampleSet.toList: (sampleSet) => list<number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toInternalSampleArray
|
||||
```
|
||||
SampleSet.toInternalSampleArray: (sampleSet) => list<number>
|
||||
```
|
||||
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.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.
|
||||
Gets the internal samples of a sampleSet distribution. This is separate from the sampleN() function, which would shuffle the samples. toList() maintains order and length. Gets the internal samples of a sampleSet distribution. This is separate from the sampleN() function, which would shuffle the samples. toList() maintains order and length.
|
||||
|
||||
|
||||
**Examples**
|
||||
```
|
||||
toInternalSampleArray(toSampleSet(normal(5,2)))
|
||||
toList(toSampleSet(normal(5,2)))
|
||||
```
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
sidebar_position: 5
|
||||
sidebar_position: 6
|
||||
title: Duration
|
||||
---
|
||||
|
||||
|
@ -8,86 +8,62 @@ title: Duration
|
|||
toString: (duration) => string
|
||||
```
|
||||
|
||||
|
||||
|
||||
### minutes
|
||||
```
|
||||
minutes: (number) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### hours
|
||||
```
|
||||
hours: (number) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### days
|
||||
```
|
||||
days: (number) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### years
|
||||
```
|
||||
years: (number) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toHours
|
||||
```
|
||||
Duration.toHours: (duration) => number
|
||||
toHours: (duration) => number
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toMinutes
|
||||
```
|
||||
Duration.toMinutes: (duration) => number
|
||||
toMinutes: (duration) => number
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toDays
|
||||
```
|
||||
Duration.toDays: (duration) => number
|
||||
toDays: (duration) => number
|
||||
```
|
||||
|
||||
|
||||
|
||||
### toYears
|
||||
```
|
||||
Duration.toYears: (duration) => number
|
||||
toYears: (duration) => number
|
||||
```
|
||||
|
||||
|
||||
|
||||
### add
|
||||
```
|
||||
add: (duration, duration) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### subtract
|
||||
```
|
||||
subtract: (duration, duration) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### multiply
|
||||
```
|
||||
multiply: (duration, duration) => duration
|
||||
multiply: (duration, number) => duration
|
||||
```
|
||||
|
||||
|
||||
|
||||
### divide
|
||||
```
|
||||
divide: (duration, duration) => duration
|
||||
divide: (duration, number) => duration
|
||||
```
|
|
@ -1,179 +1,81 @@
|
|||
---
|
||||
sidebar_position: 6
|
||||
sidebar_position: 7
|
||||
title: List
|
||||
---
|
||||
|
||||
## make
|
||||
### make
|
||||
```
|
||||
List.make: (number, 'a) => list<'a>
|
||||
List.make: (number, number => a) => list<'a>
|
||||
List.make: (pointSetDist) => list<number>
|
||||
```
|
||||
Returns an array of size ``n`` filled with value ``e``.
|
||||
|
||||
```js
|
||||
List.make(4, 1) // creates the list [1,1,1,1]
|
||||
```
|
||||
|
||||
|
||||
See [Rescript implementation](https://rescript-lang.org/docs/manual/latest/api/belt/array#make)
|
||||
|
||||
### toString
|
||||
```
|
||||
List.toString: (list<'a>) => string
|
||||
toString: (list<'a>) => string
|
||||
```
|
||||
|
||||
|
||||
|
||||
### length
|
||||
```
|
||||
List.length: (list<'a>) => number
|
||||
length: (list<'a>) => number
|
||||
```
|
||||
|
||||
|
||||
|
||||
### get
|
||||
### up to
|
||||
```
|
||||
List.get: (list<'a>, number) => 'a
|
||||
List.upTo: (low:number, high:number) => list<number>
|
||||
```
|
||||
```js
|
||||
List.upTo(0, 5) // creates the list [0,1,2,3,4,5]
|
||||
```
|
||||
|
||||
|
||||
|
||||
### find
|
||||
```
|
||||
List.find: (list<'a>, 'a => bool) => 'a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### filter
|
||||
```
|
||||
List.filter: (list<'a>, 'a => bool) => 'a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### set
|
||||
```
|
||||
List.set: (list<'a>, number, 'a) => 'a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### shuffle
|
||||
```
|
||||
List.shuffle: (list<'a>) => list<'a>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### reverse
|
||||
```
|
||||
List.reverse: (list<'a>) => list<'a>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### range
|
||||
```
|
||||
List.range: (low:number, high:number, increment?:number=1.0) => list<number>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### zip
|
||||
```
|
||||
List.zip: (list<'a>, list<'b>) => list<list<'a|b>>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### unzip
|
||||
```
|
||||
List.unzip: (list<list<'a|b>>) => list<list<'a>, list<'b>>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### concat
|
||||
```
|
||||
List.concat: (list<'a>, list<'b>) => list<'a|b>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### concatMany
|
||||
```
|
||||
List.concatMany: (list<list<'a>>) => list<'a>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### slice
|
||||
```
|
||||
List.slice:
|
||||
```
|
||||
|
||||
|
||||
|
||||
### map
|
||||
```
|
||||
List.map: (list<'a>, a => b) => list<'b>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### reduce
|
||||
```
|
||||
List.reduce:
|
||||
```
|
||||
|
||||
|
||||
|
||||
### reduceRight
|
||||
```
|
||||
List.reduceRight:
|
||||
```
|
||||
|
||||
|
||||
|
||||
### includes
|
||||
```
|
||||
List.includes: (list<'a>, 'a => bool) => boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
### every
|
||||
```
|
||||
List.every: (list<'a>, 'a => bool) => boolean
|
||||
```
|
||||
|
||||
|
||||
|
||||
### truncate
|
||||
```
|
||||
List.truncate: (list<'a>, number) => list<'a>
|
||||
```
|
||||
|
||||
|
||||
|
||||
### uniq
|
||||
```
|
||||
List.uniq: (list<'a>) => list<'a>
|
||||
```
|
||||
|
||||
|
||||
Syntax taken from [Ruby](https://apidock.com/ruby/v2_5_5/Integer/upto).
|
||||
|
||||
### first
|
||||
```
|
||||
List.first: (list<'a>) => 'a
|
||||
first: (list<'a>) => 'a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### last
|
||||
```
|
||||
List.last: (list<'a>) => 'a
|
||||
last: (list<'a>) => 'a
|
||||
```
|
||||
|
||||
|
||||
|
||||
### sort
|
||||
### reverse
|
||||
```
|
||||
List.sort: (list<'a>) => list<'a>
|
||||
reverse: (list<'a>) => list<'a>
|
||||
```
|
||||
|
||||
### map
|
||||
```
|
||||
map: (list<'a>, a => b) => list<'b>
|
||||
```
|
||||
|
||||
See [Rescript implementation](https://rescript-lang.org/docs/manual/latest/api/belt/array#map).
|
||||
|
||||
### reduce
|
||||
```
|
||||
reduce: (list<'b>, 'a, ('a, 'b) => 'a) => 'a
|
||||
```
|
||||
``reduce(arr, init, f)``
|
||||
|
||||
Applies ``f`` to each element of ``arr``. The function ``f`` has two paramaters, an accumulator and the next value from the array.
|
||||
|
||||
```js
|
||||
reduce([2, 3, 4], 1, {|acc, value| acc + value}) == 10
|
||||
```
|
||||
|
||||
See [Rescript implementation](https://rescript-lang.org/docs/manual/latest/api/belt/array#reduce).
|
||||
|
||||
### reduce reverse
|
||||
```
|
||||
reduceReverse: (list<'b>, 'a, ('a, 'b) => 'a) => 'a
|
||||
```
|
||||
|
||||
Works like ``reduce``, but the function is applied to each item from the last back to the first.
|
||||
|
||||
See [Rescript implementation](https://rescript-lang.org/docs/manual/latest/api/belt/array#reducereverse).
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
sidebar_position: 7
|
||||
sidebar_position: 8
|
||||
title: Math
|
||||
---
|
||||
|
||||
|
@ -7,25 +7,19 @@ title: Math
|
|||
```
|
||||
Math.E:
|
||||
```
|
||||
Euler's number; ≈ 2.718281828459045Euler's number; ≈ 2.718281828459045
|
||||
|
||||
|
||||
Euler's number; ≈ 2.718281828459045
|
||||
|
||||
### LN2
|
||||
```
|
||||
Math.LN2:
|
||||
```
|
||||
Natural logarithm of 2; ≈ 0.6931471805599453Natural logarithm of 2; ≈ 0.6931471805599453
|
||||
|
||||
|
||||
Natural logarithm of 2; ≈ 0.6931471805599453
|
||||
|
||||
### LN10
|
||||
```
|
||||
Math.LN10:
|
||||
```
|
||||
Natural logarithm of 10; ≈ 2.302585092994046Natural logarithm of 10; ≈ 2.302585092994046
|
||||
|
||||
|
||||
Natural logarithm of 10; ≈ 2.302585092994046
|
||||
|
||||
### LOG2E
|
||||
```
|
||||
|
@ -33,57 +27,38 @@ Math.LOG2E:
|
|||
```
|
||||
Base 2 logarithm of E; ≈ 1.4426950408889634Base 2 logarithm of E; ≈ 1.4426950408889634
|
||||
|
||||
|
||||
|
||||
### LOG10E
|
||||
```
|
||||
Math.LOG10E:
|
||||
```
|
||||
Base 10 logarithm of E; ≈ 0.4342944819032518Base 10 logarithm of E; ≈ 0.4342944819032518
|
||||
|
||||
|
||||
Base 10 logarithm of E; ≈ 0.4342944819032518
|
||||
|
||||
### PI
|
||||
```
|
||||
Math.PI:
|
||||
```
|
||||
Pi - ratio of the circumference to the diameter of a circle; ≈ 3.141592653589793Pi - ratio of the circumference to the diameter of a circle; ≈ 3.141592653589793
|
||||
|
||||
|
||||
Pi - ratio of the circumference to the diameter of a circle; ≈ 3.141592653589793
|
||||
|
||||
### SQRT1_2
|
||||
```
|
||||
Math.SQRT1_2:
|
||||
```
|
||||
Square root of 1/2; ≈ 0.7071067811865476Square root of 1/2; ≈ 0.7071067811865476
|
||||
|
||||
|
||||
Square root of 1/2; ≈ 0.7071067811865476
|
||||
|
||||
### SQRT2
|
||||
```
|
||||
Math.SQRT2:
|
||||
```
|
||||
Square root of 2; ≈ 1.4142135623730951Square root of 2; ≈ 1.4142135623730951
|
||||
|
||||
|
||||
Square root of 2; ≈ 1.4142135623730951
|
||||
|
||||
### PHI
|
||||
```
|
||||
Math.PHI:
|
||||
```
|
||||
Phi is the golden ratio. 1.618033988749895Phi is the golden ratio. 1.618033988749895
|
||||
|
||||
|
||||
Phi is the golden ratio. 1.618033988749895
|
||||
|
||||
### TAU
|
||||
```
|
||||
Math.TAU:
|
||||
```
|
||||
Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi. 6.283185307179586Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi. 6.283185307179586
|
||||
|
||||
|
||||
|
||||
### Infinity
|
||||
```
|
||||
Math.Infinity:
|
||||
```
|
||||
Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi. 6.283185307179586
|
||||
|
|
|
@ -1,166 +1,136 @@
|
|||
---
|
||||
sidebar_position: 8
|
||||
sidebar_position: 9
|
||||
title: Number
|
||||
---
|
||||
|
||||
### ceil
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
ceil: (number) => number
|
||||
```
|
||||
|
||||
### floor
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
floor: (number) => number
|
||||
```
|
||||
|
||||
### abs
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
abs: (number) => number
|
||||
```
|
||||
|
||||
### round
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
round: (number) => number
|
||||
```
|
||||
|
||||
### max
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
```
|
||||
|
||||
### maxBy
|
||||
|
||||
```javascript
|
||||
(list<number>, fn(element)):number
|
||||
max: (list<number>) => number
|
||||
```
|
||||
|
||||
### min
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
```
|
||||
|
||||
### minBy
|
||||
|
||||
```javascript
|
||||
(list<number>, fn(element)):number
|
||||
```
|
||||
|
||||
### random
|
||||
|
||||
```javascript
|
||||
number;
|
||||
```
|
||||
|
||||
### randomInt
|
||||
|
||||
```javascript
|
||||
number;
|
||||
min: (list<number>) => number
|
||||
```
|
||||
|
||||
### mean
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
mean: (list<number>) => number
|
||||
```
|
||||
|
||||
### median
|
||||
### stdev
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
```
|
||||
|
||||
### mode
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
```
|
||||
|
||||
### std
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
stdev: (list<number>) => number
|
||||
```
|
||||
|
||||
### variance
|
||||
|
||||
```javascript
|
||||
(list<number>): number
|
||||
variance: (list<number>) => number
|
||||
```
|
||||
|
||||
### unaryMinus
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
unaryMinus: (number) => number
|
||||
```
|
||||
|
||||
### equal
|
||||
|
||||
```javascript
|
||||
(number, number): boolean
|
||||
equal: (number, number) => boolean
|
||||
```
|
||||
|
||||
### add
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
add: (number, number) => number
|
||||
```
|
||||
|
||||
### sum
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
sum: (list<number>) => number
|
||||
```
|
||||
|
||||
### cumulative sum
|
||||
|
||||
```
|
||||
cumsum: (list<number>) => list<number>
|
||||
```
|
||||
|
||||
### multiply
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
multiply: (number, number) => number
|
||||
```
|
||||
|
||||
### product
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
product: (list<number>) => number
|
||||
```
|
||||
|
||||
### cumulative product
|
||||
|
||||
```
|
||||
cumprod: (list<number>) => list<number>
|
||||
```
|
||||
|
||||
### subtract
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
subtract: (number, number) => number
|
||||
```
|
||||
|
||||
### divide
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
divide: (number, number) => number
|
||||
```
|
||||
|
||||
### pow
|
||||
|
||||
```javascript
|
||||
(number, number): number
|
||||
pow: (number, number) => number
|
||||
```
|
||||
|
||||
### exp
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
exp: (number) => number
|
||||
```
|
||||
|
||||
### log
|
||||
|
||||
```javascript
|
||||
(number, number=Math.e): number
|
||||
```
|
||||
|
||||
### log10
|
||||
|
||||
```javascript
|
||||
(number): number
|
||||
log: (number) => number
|
||||
```
|
Loading…
Reference in New Issue
Block a user