Moved API files to API directory

This commit is contained in:
Ozzie Gooen 2022-06-05 20:02:17 -07:00
parent 4409ceb6c7
commit 6567f1b8ef
15 changed files with 518 additions and 476 deletions

View File

@ -49,7 +49,7 @@ let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
let registry = [
Function.make(
~name="Normal Distribution",
~name="Normal",
~examples=`normal(5,1)
normal({p5: 4, p95: 10})
normal({mean: 5, stdev: 2})`,
@ -63,7 +63,7 @@ normal({mean: 5, stdev: 2})`,
(),
),
Function.make(
~name="Lognormal Distribution",
~name="Lognormal",
~examples=`lognormal(0.5, 0.8)
lognormal({p5: 4, p95: 10})
lognormal({mean: 5, stdev: 2})`,
@ -77,31 +77,31 @@ lognormal({mean: 5, stdev: 2})`,
(),
),
Function.make(
~name="Uniform Distribution",
~name="Uniform",
~examples=`uniform(10, 12)`,
~definitions=[TwoArgDist.make("uniform", twoArgs(SymbolicDist.Uniform.make))],
(),
),
Function.make(
~name="Beta Distribution",
~name="Beta",
~examples=`beta(20, 25)`,
~definitions=[TwoArgDist.make("beta", twoArgs(SymbolicDist.Beta.make))],
(),
),
Function.make(
~name="Cauchy Distribution",
~name="Cauchy",
~examples=`cauchy(5, 1)`,
~definitions=[TwoArgDist.make("cauchy", twoArgs(SymbolicDist.Cauchy.make))],
(),
),
Function.make(
~name="Gamma Distribution",
~name="Gamma",
~examples=`gamma(5, 1)`,
~definitions=[TwoArgDist.make("gamma", twoArgs(SymbolicDist.Gamma.make))],
(),
),
Function.make(
~name="Logistic Distribution",
~name="Logistic",
~examples=`gamma(5, 1)`,
~definitions=[TwoArgDist.make("logistic", twoArgs(SymbolicDist.Logistic.make))],
(),

View File

@ -1,6 +1,6 @@
---
sidebar_position: 9
title: Dict
sidebar_position: 1
title: Dictionary
---
### toString

View File

@ -2,8 +2,244 @@
sidebar_position: 2
title: Distribution
---
import TOCInline from '@theme/TOCInline';
<TOCInline toc={toc} />
## Creation
### Normal Distribution
**Definitions**
```javascript
normal(frValueDistOrNumber, frValueDistOrNumber);
```
```javascript
normal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
```
```javascript
normal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
```
**Examples**
```javascript
normal(5, 1);
normal({ p5: 4, p95: 10 });
normal({ mean: 5, stdev: 2 });
```
### Lognormal Distribution
**Definitions**
```javascript
lognormal(frValueDistOrNumber, frValueDistOrNumber);
```
```javascript
lognormal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
```
```javascript
lognormal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
```
**Examples**
```javascript
lognormal(0.5, 0.8);
lognormal({ p5: 4, p95: 10 });
lognormal({ mean: 5, stdev: 2 });
```
### Uniform Distribution
**Definitions**
```javascript
uniform(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
uniform(10, 12);
```
### Beta Distribution
**Definitions**
```javascript
beta(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
beta(20, 25);
```
### Cauchy Distribution
**Definitions**
```javascript
cauchy(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
cauchy(5, 1);
```
### Gamma Distribution
**Definitions**
```javascript
gamma(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
gamma(5, 1);
```
### Logistic Distribution
**Definitions**
```javascript
logistic(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
gamma(5, 1);
```
### To (Distribution)
**Definitions**
```javascript
to(frValueDistOrNumber, frValueDistOrNumber);
```
```javascript
credibleIntervalToDistribution(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
5 to 10
to(5,10)
-5 to 5
```
### Exponential
**Definitions**
```javascript
exponential(frValueDistOrNumber);
```
**Examples**
```javascript
exponential(2);
```
### Bernoulli
**Definitions**
```javascript
bernoulli(frValueDistOrNumber);
```
**Examples**
```javascript
bernoulli(0.5);
```
### toContinuousPointSet
Converts a set of points to a continuous distribution
**Definitions**
```javascript
toContinuousPointSet(array<dict<{x: numeric, y: numeric}>>)
```
**Examples**
```javascript
toContinuousPointSet([
{ x: 0, y: 0.1 },
{ x: 1, y: 0.2 },
{ x: 2, y: 0.15 },
{ x: 3, y: 0.1 },
]);
```
### toDiscretePointSet
Converts a set of points to a discrete distribution
**Definitions**
```javascript
toDiscretePointSet(array<dict<{x: numeric, y: numeric}>>)
```
**Examples**
```javascript
toDiscretePointSet([
{ x: 0, y: 0.1 },
{ x: 1, y: 0.2 },
{ x: 2, y: 0.15 },
{ x: 3, y: 0.1 },
]);
```
### 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
## Main
### mixture
@ -181,6 +417,8 @@ Truncates the right side of a distribution. Returns either a pointSet distributi
truncateLeft(normal(5, 2), 6);
```
## Scoring
### klDivergence
KullbackLeibler divergence between two distributions
@ -207,6 +445,8 @@ klDivergence(normal(5, 2), normal(5, 4)); // returns 0.57
logScore({ estimate: normal(5, 2), prior: normal(5.5, 4), answer: 2.3 });
```
## Display
### toString
```javascript
@ -247,6 +487,8 @@ Prints the value of the distribution to the Javascript console, then returns the
inspect(normal(5, 2));
```
## Normalization
### normalize
Normalize a distribution. This means scaling it appropriately so that it's cumulative sum is equal to 1.
@ -289,6 +531,8 @@ Get the sum of the integral of a distribution. If the distribution is normalized
integralSum(normal(5, 2));
```
## Algebra1
### add
```javascript
@ -355,6 +599,8 @@ integralSum(normal(5, 2));
(distribution):distribution
```
## Algebra2
### dotAdd
```javascript
@ -403,6 +649,8 @@ integralSum(normal(5, 2));
(distributionLike, distributionLike): distribution
```
## Algebra3
### scaleMultiply
```javascript

View File

@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 3
title: Point Set Distribution
---

View File

@ -0,0 +1,67 @@
---
sidebar_position: 4
title: Sample Set Distribution
---
### make
```javascript
make: (distribution) => sampleSet
make: (() => number) => sampleSet
make: (list<number>) => sampleSet
```
### kde
```javascript
kde: (sampleSet) => pointSetDist
```
### toEmpiricalPdf
```javascript
toEmpiricalPdf: (sampleSet) => pointSetDist
```
### map
```javascript
map: (sampleSet, (number => number)) => sampleSet
```
### map2
```javascript
map2: (sampleSet, sampleSet, ((number, number) => number)) => sampleSet
```
### map3
```javascript
map3: (sampleSet, sampleSet, sampleSet, ((number, number, number) => number)) => sampleSet
```
### correlation
```javascript
correlation: (sampleSet, sampleSet) => number
```
### toInternalSampleArray
```javascript
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.
**Examples**
```javascript
toInternalSampleArray(toSampleSet(normal(5,2)))
```

View File

@ -1,234 +0,0 @@
---
sidebar_position: 1
title: Distribution Creation
---
## Normal Distribution
**Definitions**
```javascript
normal(frValueDistOrNumber, frValueDistOrNumber);
```
```javascript
normal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
```
```javascript
normal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
```
**Examples**
```javascript
normal(5, 1);
normal({ p5: 4, p95: 10 });
normal({ mean: 5, stdev: 2 });
```
## Lognormal Distribution
**Definitions**
```javascript
lognormal(frValueDistOrNumber, frValueDistOrNumber);
```
```javascript
lognormal(dict<{p5: frValueDistOrNumber, p95: frValueDistOrNumber}>)
```
```javascript
lognormal(dict<{mean: frValueDistOrNumber, stdev: frValueDistOrNumber}>)
```
**Examples**
```javascript
lognormal(0.5, 0.8);
lognormal({ p5: 4, p95: 10 });
lognormal({ mean: 5, stdev: 2 });
```
## Uniform Distribution
**Definitions**
```javascript
uniform(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
uniform(10, 12);
```
## Beta Distribution
**Definitions**
```javascript
beta(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
beta(20, 25);
```
## Cauchy Distribution
**Definitions**
```javascript
cauchy(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
cauchy(5, 1);
```
## Gamma Distribution
**Definitions**
```javascript
gamma(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
gamma(5, 1);
```
## Logistic Distribution
**Definitions**
```javascript
logistic(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
gamma(5, 1);
```
## To (Distribution)
**Definitions**
```javascript
to(frValueDistOrNumber, frValueDistOrNumber);
```
```javascript
credibleIntervalToDistribution(frValueDistOrNumber, frValueDistOrNumber);
```
**Examples**
```javascript
5 to 10
to(5,10)
-5 to 5
```
## Exponential
**Definitions**
```javascript
exponential(frValueDistOrNumber);
```
**Examples**
```javascript
exponential(2);
```
## Bernoulli
**Definitions**
```javascript
bernoulli(frValueDistOrNumber);
```
**Examples**
```javascript
bernoulli(0.5);
```
## toContinuousPointSet
Converts a set of points to a continuous distribution
**Definitions**
```javascript
toContinuousPointSet(array<dict<{x: numeric, y: numeric}>>)
```
**Examples**
```javascript
toContinuousPointSet([
{ x: 0, y: 0.1 },
{ x: 1, y: 0.2 },
{ x: 2, y: 0.15 },
{ x: 3, y: 0.1 },
]);
```
## toDiscretePointSet
Converts a set of points to a discrete distribution
**Definitions**
```javascript
toDiscretePointSet(array<dict<{x: numeric, y: numeric}>>)
```
**Examples**
```javascript
toDiscretePointSet([
{ x: 0, y: 0.1 },
{ x: 1, y: 0.2 },
{ x: 2, y: 0.15 },
{ x: 3, y: 0.1 },
]);
```
## 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}
]
})
```

View File

@ -1,5 +1,5 @@
---
sidebar_position: 10
sidebar_position: 5
title: Duration
---

View File

@ -1,160 +0,0 @@
---
sidebar_position: 4
title: List
---
### toString
```javascript
(list<'a>):string
```
### length
```javascript
(list<'a>):number
```
### get
```javascript
(list<a>, number):a
```
### find
```javascript
(list<a>, e => bool):a
```
### filter
```javascript
(list<a>, e => bool):a
```
### set
```javascript
(list<a>, number, a):a
```
### shuffle
```javascript
(list<a>):list<a>
```
### reverse
```javascript
(list<a>):list<a>
```
### make
```javascript
(number,a):list<a> (number, (index:number => a)):list<a> (pointSetDist):list<number>
```
### range
```javascript
(low:number, high:number) => list<number>
```
### rangeBy
```javascript
(low:number, high:number, increment: number) => list<number>
```
### zip
```javascript
(list<a>, list<b>):list<list<a|b>>
```
### unzip
```javascript
(list<list<a|b>>):list<list<a>, list<b>>
```
### concat
```javascript
(list<a>, list<b>): list<a|b>
```
### concatMany
```javascript
(list<list<a>>):list<a>
```
### slice
```javascript
```
### map
```javascript
(list<a>, (a -> b)): list<b>
```
### reduce
```javascript
```
### reduceRight
```javascript
```
### includes
```javascript
(list<'a>, 'a => bool):boolean
```
### every
```javascript
(list<'a>, 'a => bool):boolean
```
### truncate
```javascript
(list<'a>, number):list<'a>
```
### uniq
```javascript
(list<'a>):list
```
### first
```javascript
(list<'a>):'a
```
### last
```javascript
(list<'a>):'a
```
### sort
```javascript
(list<'a>):list
```

View File

@ -0,0 +1,176 @@
---
sidebar_position: 6
title: List
---
### make
```javascript
make: (number, 'a) => list<'a> (number, number => a) => list<'a> (pointSetDist) => list<number>
```
### toString
```typescript
toString: (list<'a>) => string
```
### length
```typescript
length: (list<'a>) => number
```
### get
```typescript
get: (list<'a>, number) => 'a
```
### find
```typescript
find: (list<'a>, 'a => bool) => 'a
```
### filter
```typescript
filter: (list<'a>, 'a => bool) => 'a
```
### set
```typescript
set: (list<'a>, number, 'a) => 'a
```
### shuffle
```typescript
shuffle: (list<'a>) => list<'a>
```
### reverse
```typescript
reverse: (list<'a>) => list<'a>
```
### range
```typescript
range: (low:number, high:number, increment?:number=1.0) => list<number>
```
### zip
```typescript
zip: (list<'a>, list<'b>) => list<list<'a|b>>
```
### unzip
```typescript
unzip: (list<list<'a|b>>) => list<list<'a>, list<'b>>
```
### concat
```typescript
concat: (list<'a>, list<'b>) => list<'a|b>
```
### concatMany
```typescript
concatMany: (list<list<'a>>) => list<'a>
```
### slice
```typescript
slice:
```
### map
```typescript
map: (list<'a>, a => b) => list<'b>
```
### reduce
```typescript
reduce:
```
### reduceRight
```typescript
reduceRight:
```
### includes
```typescript
includes: (list<'a>, 'a => bool) => boolean
```
### every
```typescript
every: (list<'a>, 'a => bool) => boolean
```
### truncate
```typescript
truncate: (list<'a>, number) => list<'a>
```
### uniq
```typescript
uniq: (list<'a>) => list<'a>
```
### first
```typescript
first: (list<'a>) => 'a
```
### last
```typescript
last: (list<'a>) => 'a
```
### sort
```typescript
sort: (list<'a>) => list<'a>
```

View File

@ -1,5 +1,5 @@
---
sidebar_position: 5
sidebar_position: 7
title: Math
---

View File

@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 8
title: Number
---

View File

@ -1,54 +0,0 @@
---
sidebar_position: 8
title: Sample Set 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.
```javascript
(sampleSet):list<number>
```
**Examples**
```javascript
toInternalSampleArray(toSampleSet(normal(5, 2)));
```
### kde
```javascript
(sampleSet):pointSetDist
```
### toEmpiricalPdf
```javascript
(sampleSet):pointSetDist
```
### map
```javascript
(sampleSet, (r => number)): sampleSet
```
### map2
```javascript
(sampleSet, sampleSet, ((d1, d2)=>number)): sampleSet
```
### map3
```javascript
(sampleSet, sampleSet, sampleSet, ((d1, d2, d3)=>number)): sampleSet
```
### make
```javascript
(dist): sampleSet (()=>number): sampleSet (list<number>): sampleSet
```

View File

@ -1,16 +1,13 @@
---
title: "Distribution Creation"
sidebar_position: 2
sidebar_position: 20
---
import TOCInline from "@theme/TOCInline";
import { SquiggleEditor } from "../../src/components/SquiggleEditor";
import Admonition from "@theme/Admonition";
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
<TOCInline toc={toc} maxHeadingLevel={2} />
## To
`(5thPercentile: number) to (95thPercentile: number)`

View File

@ -82,6 +82,12 @@ const config = {
position: "left",
label: "Documentation",
},
{
type: "doc",
docId: "Api/Dictionary",
position: "left",
label: "API",
},
{ to: "/blog", label: "Blog", position: "left" },
{ to: "/playground", label: "Playground", position: "left" },
{

View File

@ -14,6 +14,12 @@
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
// By default, Docusaurus generates a sidebar from the docs folder structure
apiSidebar: [
{
type: 'autogenerated',
dirName: 'Api',
},
],
tutorialSidebar: [
{
type: "doc",
@ -30,16 +36,6 @@ const sidebars = {
},
],
},
{
type: "category",
label: "API",
items: [
{
type: "autogenerated",
dirName: "Api",
},
],
},
{
type: "category",
label: "Discussions",