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("2>1", "Ok(true)")
|
||||||
testEval("concat('a','b')", "Ok('ab')")
|
testEval("concat('a','b')", "Ok('ab')")
|
||||||
testEval(
|
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])",
|
"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
|
EV.EvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some
|
||||||
| ("divide", [EvTimeDuration(d1), EvNumber(d2)]) =>
|
| ("divide", [EvTimeDuration(d1), EvNumber(d2)]) =>
|
||||||
EV.EvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some
|
EV.EvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some
|
||||||
|
| ("divide", [EvTimeDuration(d1), EvTimeDuration(d2)]) =>
|
||||||
|
EV.EvNumber(d1 /. d2)->Ok->Some
|
||||||
| _ => None
|
| _ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,7 @@ let dispatchToGenericOutput = (
|
||||||
Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist, ~env)
|
Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist, ~env)
|
||||||
| ("toSampleSet", [EvDistribution(dist)]) =>
|
| ("toSampleSet", [EvDistribution(dist)]) =>
|
||||||
Helpers.toDistFn(ToSampleSet(env.sampleCount), dist, ~env)
|
Helpers.toDistFn(ToSampleSet(env.sampleCount), dist, ~env)
|
||||||
| ("toInternalSampleArray", [EvDistribution(SampleSet(dist))]) =>
|
| ("toList", [EvDistribution(SampleSet(dist))]) =>
|
||||||
Some(FloatArray(SampleSetDist.T.get(dist)))
|
Some(FloatArray(SampleSetDist.T.get(dist)))
|
||||||
| ("fromSamples", [EvArray(inputArray)]) => {
|
| ("fromSamples", [EvArray(inputArray)]) => {
|
||||||
let _wrapInputErrors = x => SampleSetDist.NonNumericInput(x)
|
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
|
title: Dictionary
|
||||||
---
|
---
|
||||||
|
### toList
|
||||||
### toString
|
|
||||||
```
|
```
|
||||||
toString: (dict<'a>) => string
|
Dict.toList: (dict<'a>) => list<list<string|a>>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
Dict.toList({foo: 3, bar: 20}) // [["foo", 3], ["bar", 20]]
|
||||||
### get
|
|
||||||
```
|
|
||||||
Dict.get: (dict<'a>, string) => a
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### fromList
|
||||||
|
|
||||||
### set
|
|
||||||
```
|
```
|
||||||
Dict.set: (dict<'a>, string, a) => a
|
Dict.fromList: (list<list<string|'a>>) => dict<'a>
|
||||||
```
|
```
|
||||||
|
```js
|
||||||
|
Dict.fromList([["foo", 3], ["bar", 20]]) // {foo: 3, bar: 20}
|
||||||
|
|
||||||
### toPairs
|
|
||||||
```
|
```
|
||||||
Dict.toPairs: (dict<'a>) => list<list<string|a>>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### keys
|
### keys
|
||||||
```
|
```
|
||||||
Dict.keys: (dict<'a>) => list<string>
|
Dict.keys: (dict<'a>) => list<string>
|
||||||
```
|
```
|
||||||
|
```js
|
||||||
|
Dict.keys({foo: 3, bar: 20}) // ["foo", "bar"]
|
||||||
|
```
|
||||||
|
|
||||||
### values
|
### values
|
||||||
```
|
```
|
||||||
Dict.values: (dict<'a>) => list<'a>
|
Dict.values: (dict<'a>) => list<'a>
|
||||||
```
|
```
|
||||||
|
```js
|
||||||
|
Dict.values({foo: 3, bar: 20}) // [3,20]
|
||||||
|
```
|
||||||
|
|
||||||
### merge
|
### merge
|
||||||
```
|
```
|
||||||
Dict.merge: (dict<'a>, dict<'b>) => dict<'a|b>
|
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
|
### mergeMany
|
||||||
```
|
```
|
||||||
Dict.mergeMany: (list<dict<'a>>) => dict<'a>
|
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
|
title: Distribution
|
||||||
---
|
---
|
||||||
import TOCInline from '@theme/TOCInline';
|
|
||||||
|
import TOCInline from "@theme/TOCInline";
|
||||||
|
|
||||||
<TOCInline toc={toc} />
|
<TOCInline toc={toc} />
|
||||||
|
|
||||||
## Creation
|
## Distribution Creation
|
||||||
|
|
||||||
### Normal Distribution
|
### Normal Distribution
|
||||||
|
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
normal(frValueDistOrNumber, frValueDistOrNumber);
|
normal: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
normal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
normal: (dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
normal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
normal: (dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```js
|
||||||
normal(5, 1);
|
normal(5, 1);
|
||||||
normal({ p5: 4, p95: 10 });
|
normal({ p5: 4, p95: 10 });
|
||||||
normal({ mean: 5, stdev: 2 });
|
normal({ mean: 5, stdev: 2 });
|
||||||
|
@ -37,15 +38,15 @@ normal({ mean: 5, stdev: 2 });
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
lognormal(frValueDistOrNumber, frValueDistOrNumber);
|
lognormal: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
lognormal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
lognormal: (dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
lognormal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
lognormal: (dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -61,7 +62,7 @@ lognormal({ mean: 5, stdev: 2 });
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
uniform(frValueDistOrNumber, frValueDistOrNumber);
|
uniform: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -75,7 +76,7 @@ uniform(10, 12);
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
beta(frValueDistOrNumber, frValueDistOrNumber);
|
beta: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -89,7 +90,7 @@ beta(20, 25);
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
cauchy(frValueDistOrNumber, frValueDistOrNumber);
|
cauchy: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -103,7 +104,7 @@ cauchy(5, 1);
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
gamma(frValueDistOrNumber, frValueDistOrNumber);
|
gamma: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -117,7 +118,7 @@ gamma(5, 1);
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
logistic(frValueDistOrNumber, frValueDistOrNumber);
|
logistic: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -131,7 +132,7 @@ gamma(5, 1);
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
to(frValueDistOrNumber, frValueDistOrNumber);
|
to: (frValueDistOrNumber, frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -151,7 +152,7 @@ to(5,10)
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
exponential(frValueDistOrNumber);
|
exponential: (frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -165,7 +166,7 @@ exponential(2);
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
bernoulli(frValueDistOrNumber);
|
bernoulli: (frValueDistOrNumber);
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -181,7 +182,7 @@ Converts a set of points to a continuous distribution
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
toContinuousPointSet(array<dict<{x: numeric, y: numeric}>>)
|
toContinuousPointSet: (array<dict<{x: numeric, y: numeric}>>)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -202,7 +203,7 @@ Converts a set of points to a discrete distribution
|
||||||
**Definitions**
|
**Definitions**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
toDiscretePointSet(array<dict<{x: numeric, y: numeric}>>)
|
toDiscretePointSet: (array<dict<{x: numeric, y: numeric}>>)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**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
|
## Functions
|
||||||
|
|
||||||
|
|
||||||
### mixture
|
### mixture
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(...distributionLike, weights:list<float>):distribution
|
mixture: (...distributionLike, weights:list<float>):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
mixture(normal(5, 1), normal(10, 1));
|
mixture(normal(5, 1), normal(10, 1));
|
||||||
|
mx(normal(5, 1), normal(10, 1), [0.3, 0.7]);
|
||||||
```
|
```
|
||||||
|
|
||||||
### sample
|
### sample
|
||||||
|
@ -258,7 +237,7 @@ mixture(normal(5, 1), normal(10, 1));
|
||||||
Get one random sample from the distribution
|
Get one random sample from the distribution
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):number
|
sample(distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -272,13 +251,13 @@ sample(normal(5, 2));
|
||||||
Get n random samples from the distribution
|
Get n random samples from the distribution
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, number):list<number>
|
sampleN: (distribution, number):list<number>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
sample(normal(5, 2), 100);
|
sample: (normal(5, 2), 100);
|
||||||
```
|
```
|
||||||
|
|
||||||
### mean
|
### mean
|
||||||
|
@ -286,73 +265,61 @@ sample(normal(5, 2), 100);
|
||||||
Get the distribution mean
|
Get the distribution mean
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):number
|
mean: (distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
mean(normal(5, 2));
|
mean: (normal(5, 2));
|
||||||
```
|
```
|
||||||
|
|
||||||
### stdev
|
### stdev
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):number
|
stdev: (distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
### variance
|
### variance
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):number
|
variance: (distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
### mode
|
### mode
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):number
|
mode: (distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
### cdf
|
### cdf
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, number):number
|
cdf: (distribution, number):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
cdf(normal(5, 2), 3);
|
cdf: (normal(5, 2), 3);
|
||||||
```
|
```
|
||||||
|
|
||||||
### pdf
|
### pdf
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, number):number
|
pdf: (distribution, number):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
pdf(normal(5, 2), 3);
|
pdf: (normal(5, 2), 3);
|
||||||
```
|
|
||||||
|
|
||||||
### pmf
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(distribution, number):number
|
|
||||||
```
|
|
||||||
|
|
||||||
**Examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
pmf(bernoulli(0.3), 0); // 0.7
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### inv
|
### inv
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, number):number
|
inv: (distribution, number):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -366,7 +333,7 @@ inv(normal(5, 2), 0.5);
|
||||||
Converts a distribution to the pointSet format
|
Converts a distribution to the pointSet format
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):pointSetDistribution
|
toPointSet: (distribution):pointSetDistribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -380,13 +347,13 @@ toPointSet(normal(5, 2));
|
||||||
Converts a distribution to the sampleSet format, with n samples
|
Converts a distribution to the sampleSet format, with n samples
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution,n):sampleSetribution
|
toSampleSet: (distribution,number):sampleSetDistribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
toSampleSet(normal(5, 2));
|
toSampleSet(normal(5, 2), 1000);
|
||||||
```
|
```
|
||||||
|
|
||||||
### truncateLeft
|
### 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.
|
Truncates the left side of a distribution. Returns either a pointSet distribution or a symbolic distribution.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, l:number, {normalize: boolean=true}):distribution
|
truncateLeft: (distribution, l:number):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**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.
|
Truncates the right side of a distribution. Returns either a pointSet distribution or a symbolic distribution.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, r:number, {normalize: boolean=true}):distribution
|
truncateRight: (distribution, r:number):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -424,7 +391,7 @@ truncateLeft(normal(5, 2), 6);
|
||||||
Kullback–Leibler divergence between two distributions
|
Kullback–Leibler divergence between two distributions
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, distribution):number
|
klDivergence: (distribution, distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -433,24 +400,12 @@ Kullback–Leibler divergence between two distributions
|
||||||
klDivergence(normal(5, 2), normal(5, 4)); // returns 0.57
|
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
|
## Display
|
||||||
|
|
||||||
### toString
|
### toString
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):string
|
: (distribution):string
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -464,7 +419,7 @@ toString(normal(5, 2));
|
||||||
Produce a sparkline of length n
|
Produce a sparkline of length n
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution, n=20):string
|
toSparkline: (distribution, n=20):string
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -478,7 +433,7 @@ toSparkline(normal(5, 2), 10);
|
||||||
Prints the value of the distribution to the Javascript console, then returns the distribution.
|
Prints the value of the distribution to the Javascript console, then returns the distribution.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):distribution
|
inspect: (distribution):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**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.
|
Normalize a distribution. This means scaling it appropriately so that it's cumulative sum is equal to 1.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):distribution
|
normalize: (distribution):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**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.
|
Check of a distribution is normalized. Most distributions are typically normalized, but there are some commands that could produce non-normalized distributions.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):bool
|
isNormalized: (distribution):bool
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**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.
|
Get the sum of the integral of a distribution. If the distribution is normalized, this will be 1.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):number
|
integralSum: (distribution):number
|
||||||
```
|
```
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
@ -531,158 +486,162 @@ Get the sum of the integral of a distribution. If the distribution is normalized
|
||||||
integralSum(normal(5, 2));
|
integralSum(normal(5, 2));
|
||||||
```
|
```
|
||||||
|
|
||||||
## Algebra1
|
## Algebraic Operations
|
||||||
|
|
||||||
### add
|
### add
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
add: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### sum
|
### sum
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<distributionLike>): distribution
|
sum: (list<distributionLike>): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### multiply
|
### multiply
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
multiply: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### product
|
### product
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<distributionLike>): distribution
|
product: (list<distributionLike>): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### subtract
|
### subtract
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
subtract: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### divide
|
### divide
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
divide: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### pow
|
### pow
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
pow: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### exp
|
### exp
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
exp: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### log
|
### log
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
log: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### log10
|
### log10
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike):distribution
|
log10: (distributionLike, distributionLike):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### unaryMinus
|
### unaryMinus
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distribution):distribution
|
unaryMinus: (distribution):distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
## Algebra2
|
## Pointwise Operations
|
||||||
|
|
||||||
### dotAdd
|
### dotAdd
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
dotAdd: (distributionLike, distributionLike): distribution
|
||||||
```
|
|
||||||
|
|
||||||
### dotSum
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(list<distributionLike>): distribution
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### dotMultiply
|
### dotMultiply
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
dotMultiply: (distributionLike, distributionLike): distribution
|
||||||
```
|
|
||||||
|
|
||||||
### dotProduct
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(list<distributionLike>): distribution
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### dotSubtract
|
### dotSubtract
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
dotSubtract: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### dotDivide
|
### dotDivide
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
dotDivide: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### dotPow
|
### dotPow
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
dotPow: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### dotExp
|
### dotExp
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
dotExp: (distributionLike, distributionLike): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
## Algebra3
|
## Scale Operations
|
||||||
|
|
||||||
### scaleMultiply
|
### scaleMultiply
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
scaleMultiply: (distributionLike, number): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### scalePow
|
### scalePow
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
scalePow: (distributionLike, number): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### scaleExp
|
### scaleExp
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
scaleExp: (distributionLike, number): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### scaleLog
|
### scaleLog
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(distributionLike, distributionLike): distribution
|
scaleLog: (distributionLike, number): distribution
|
||||||
```
|
```
|
||||||
|
|
||||||
### scaleLog10
|
### scaleLog10
|
||||||
|
|
||||||
```javascript
|
```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
|
```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
|
title: Point Set Distribution
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -8,23 +8,12 @@ title: Point Set Distribution
|
||||||
PointSet.make: (distribution) => pointSetDist
|
PointSet.make: (distribution) => pointSetDist
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### makeContinuous
|
### makeContinuous
|
||||||
```
|
```
|
||||||
PointSet.makeContinuous: (list<{x: number, y: number}>) => pointSetDist
|
PointSet.makeContinuous: (list<{x: number, y: number}>) => pointSetDist
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### makeDiscrete
|
### makeDiscrete
|
||||||
```
|
```
|
||||||
PointSet.makeDiscrete: (list<{x: number, y: number}>) => pointSetDist
|
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
|
title: Sample Set Distribution
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -10,58 +10,31 @@ SampleSet.make: (() => number) => sampleSet
|
||||||
SampleSet.make: (list<number>) => sampleSet
|
SampleSet.make: (list<number>) => sampleSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### kde
|
|
||||||
```
|
|
||||||
SampleSet.kde: (sampleSet) => pointSetDist
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### toEmpiricalPdf
|
|
||||||
```
|
|
||||||
SampleSet.toEmpiricalPdf: (sampleSet) => pointSetDist
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### map
|
### map
|
||||||
```
|
```
|
||||||
SampleSet.map: (sampleSet, (number => number)) => sampleSet
|
SampleSet.map: (sampleSet, (number => number)) => sampleSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### map2
|
### map2
|
||||||
```
|
```
|
||||||
SampleSet.map2: (sampleSet, sampleSet, ((number, number) => number)) => sampleSet
|
SampleSet.map2: (sampleSet, sampleSet, ((number, number) => number)) => sampleSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### map3
|
### map3
|
||||||
```
|
```
|
||||||
SampleSet.map3: (sampleSet, sampleSet, sampleSet, ((number, number, number) => number)) => sampleSet
|
SampleSet.map3: (sampleSet, sampleSet, sampleSet, ((number, number, number) => number)) => sampleSet
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### toList
|
||||||
### correlation
|
|
||||||
```
|
```
|
||||||
SampleSet.correlation: (sampleSet, sampleSet) => number
|
SampleSet.toList: (sampleSet) => list<number>
|
||||||
```
|
```
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
```
|
```
|
||||||
toInternalSampleArray(toSampleSet(normal(5,2)))
|
toList(toSampleSet(normal(5,2)))
|
||||||
```
|
```
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
sidebar_position: 5
|
sidebar_position: 6
|
||||||
title: Duration
|
title: Duration
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -8,86 +8,62 @@ title: Duration
|
||||||
toString: (duration) => string
|
toString: (duration) => string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### minutes
|
### minutes
|
||||||
```
|
```
|
||||||
minutes: (number) => duration
|
minutes: (number) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### hours
|
### hours
|
||||||
```
|
```
|
||||||
hours: (number) => duration
|
hours: (number) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### days
|
### days
|
||||||
```
|
```
|
||||||
days: (number) => duration
|
days: (number) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### years
|
### years
|
||||||
```
|
```
|
||||||
years: (number) => duration
|
years: (number) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### toHours
|
### toHours
|
||||||
```
|
```
|
||||||
Duration.toHours: (duration) => number
|
toHours: (duration) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### toMinutes
|
### toMinutes
|
||||||
```
|
```
|
||||||
Duration.toMinutes: (duration) => number
|
toMinutes: (duration) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### toDays
|
### toDays
|
||||||
```
|
```
|
||||||
Duration.toDays: (duration) => number
|
toDays: (duration) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### toYears
|
### toYears
|
||||||
```
|
```
|
||||||
Duration.toYears: (duration) => number
|
toYears: (duration) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### add
|
### add
|
||||||
```
|
```
|
||||||
add: (duration, duration) => duration
|
add: (duration, duration) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### subtract
|
### subtract
|
||||||
```
|
```
|
||||||
subtract: (duration, duration) => duration
|
subtract: (duration, duration) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### multiply
|
### multiply
|
||||||
```
|
```
|
||||||
multiply: (duration, duration) => duration
|
multiply: (duration, number) => duration
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### divide
|
### divide
|
||||||
```
|
```
|
||||||
divide: (duration, duration) => duration
|
divide: (duration, number) => duration
|
||||||
```
|
```
|
|
@ -1,179 +1,81 @@
|
||||||
---
|
---
|
||||||
sidebar_position: 6
|
sidebar_position: 7
|
||||||
title: List
|
title: List
|
||||||
---
|
---
|
||||||
|
|
||||||
## make
|
### make
|
||||||
```
|
```
|
||||||
List.make: (number, 'a) => list<'a>
|
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
|
### toString
|
||||||
```
|
```
|
||||||
List.toString: (list<'a>) => string
|
toString: (list<'a>) => string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### length
|
### length
|
||||||
```
|
```
|
||||||
List.length: (list<'a>) => number
|
length: (list<'a>) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### up to
|
||||||
|
|
||||||
### get
|
|
||||||
```
|
```
|
||||||
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]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Syntax taken from [Ruby](https://apidock.com/ruby/v2_5_5/Integer/upto).
|
||||||
|
|
||||||
### 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>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### first
|
### first
|
||||||
```
|
```
|
||||||
List.first: (list<'a>) => 'a
|
first: (list<'a>) => 'a
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### last
|
### last
|
||||||
```
|
```
|
||||||
List.last: (list<'a>) => 'a
|
last: (list<'a>) => 'a
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### reverse
|
||||||
|
|
||||||
### sort
|
|
||||||
```
|
```
|
||||||
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
|
title: Math
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -7,25 +7,19 @@ title: Math
|
||||||
```
|
```
|
||||||
Math.E:
|
Math.E:
|
||||||
```
|
```
|
||||||
Euler's number; ≈ 2.718281828459045Euler's number; ≈ 2.718281828459045
|
Euler's number; ≈ 2.718281828459045
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### LN2
|
### LN2
|
||||||
```
|
```
|
||||||
Math.LN2:
|
Math.LN2:
|
||||||
```
|
```
|
||||||
Natural logarithm of 2; ≈ 0.6931471805599453Natural logarithm of 2; ≈ 0.6931471805599453
|
Natural logarithm of 2; ≈ 0.6931471805599453
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### LN10
|
### LN10
|
||||||
```
|
```
|
||||||
Math.LN10:
|
Math.LN10:
|
||||||
```
|
```
|
||||||
Natural logarithm of 10; ≈ 2.302585092994046Natural logarithm of 10; ≈ 2.302585092994046
|
Natural logarithm of 10; ≈ 2.302585092994046
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### LOG2E
|
### LOG2E
|
||||||
```
|
```
|
||||||
|
@ -33,57 +27,38 @@ Math.LOG2E:
|
||||||
```
|
```
|
||||||
Base 2 logarithm of E; ≈ 1.4426950408889634Base 2 logarithm of E; ≈ 1.4426950408889634
|
Base 2 logarithm of E; ≈ 1.4426950408889634Base 2 logarithm of E; ≈ 1.4426950408889634
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### LOG10E
|
### LOG10E
|
||||||
```
|
```
|
||||||
Math.LOG10E:
|
Math.LOG10E:
|
||||||
```
|
```
|
||||||
Base 10 logarithm of E; ≈ 0.4342944819032518Base 10 logarithm of E; ≈ 0.4342944819032518
|
Base 10 logarithm of E; ≈ 0.4342944819032518
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### PI
|
### PI
|
||||||
```
|
```
|
||||||
Math.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
|
### SQRT1_2
|
||||||
```
|
```
|
||||||
Math.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
|
### SQRT2
|
||||||
```
|
```
|
||||||
Math.SQRT2:
|
Math.SQRT2:
|
||||||
```
|
```
|
||||||
Square root of 2; ≈ 1.4142135623730951Square root of 2; ≈ 1.4142135623730951
|
Square root of 2; ≈ 1.4142135623730951
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### PHI
|
### PHI
|
||||||
```
|
```
|
||||||
Math.PHI:
|
Math.PHI:
|
||||||
```
|
```
|
||||||
Phi is the golden ratio. 1.618033988749895Phi is the golden ratio. 1.618033988749895
|
Phi is the golden ratio. 1.618033988749895
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### TAU
|
### TAU
|
||||||
```
|
```
|
||||||
Math.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
|
Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi. 6.283185307179586
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Infinity
|
|
||||||
```
|
|
||||||
Math.Infinity:
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,166 +1,136 @@
|
||||||
---
|
---
|
||||||
sidebar_position: 8
|
sidebar_position: 9
|
||||||
title: Number
|
title: Number
|
||||||
---
|
---
|
||||||
|
|
||||||
### ceil
|
### ceil
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number): number
|
ceil: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### floor
|
### floor
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number): number
|
floor: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### abs
|
### abs
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number): number
|
abs: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### round
|
### round
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number): number
|
round: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### max
|
### max
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<number>): number
|
max: (list<number>) => number
|
||||||
```
|
|
||||||
|
|
||||||
### maxBy
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(list<number>, fn(element)):number
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### min
|
### min
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<number>): number
|
min: (list<number>) => number
|
||||||
```
|
|
||||||
|
|
||||||
### minBy
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(list<number>, fn(element)):number
|
|
||||||
```
|
|
||||||
|
|
||||||
### random
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
number;
|
|
||||||
```
|
|
||||||
|
|
||||||
### randomInt
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
number;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### mean
|
### mean
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<number>): number
|
mean: (list<number>) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### median
|
### stdev
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<number>): number
|
stdev: (list<number>) => number
|
||||||
```
|
|
||||||
|
|
||||||
### mode
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(list<number>): number
|
|
||||||
```
|
|
||||||
|
|
||||||
### std
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(list<number>): number
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### variance
|
### variance
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(list<number>): number
|
variance: (list<number>) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### unaryMinus
|
### unaryMinus
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number): number
|
unaryMinus: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### equal
|
### equal
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): boolean
|
equal: (number, number) => boolean
|
||||||
```
|
```
|
||||||
|
|
||||||
### add
|
### add
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
add: (number, number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### sum
|
### sum
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
sum: (list<number>) => number
|
||||||
|
```
|
||||||
|
|
||||||
|
### cumulative sum
|
||||||
|
|
||||||
|
```
|
||||||
|
cumsum: (list<number>) => list<number>
|
||||||
```
|
```
|
||||||
|
|
||||||
### multiply
|
### multiply
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
multiply: (number, number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### product
|
### product
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
product: (list<number>) => number
|
||||||
|
```
|
||||||
|
|
||||||
|
### cumulative product
|
||||||
|
|
||||||
|
```
|
||||||
|
cumprod: (list<number>) => list<number>
|
||||||
```
|
```
|
||||||
|
|
||||||
### subtract
|
### subtract
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
subtract: (number, number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### divide
|
### divide
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
divide: (number, number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### pow
|
### pow
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number): number
|
pow: (number, number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### exp
|
### exp
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number): number
|
exp: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### log
|
### log
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
(number, number=Math.e): number
|
log: (number) => number
|
||||||
```
|
```
|
||||||
|
|
||||||
### log10
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
(number): number
|
|
||||||
```
|
|
Loading…
Reference in New Issue
Block a user