diff --git a/packages/website/docs/Api/DistGeneric.mdx b/packages/website/docs/Api/DistGeneric.mdx index 93833f3e..47927116 100644 --- a/packages/website/docs/Api/DistGeneric.mdx +++ b/packages/website/docs/Api/DistGeneric.mdx @@ -21,9 +21,7 @@ See a longer tutorial on creating distributions [here](/docs/Guides/Distribution ### normal -**Definitions** - -```javascript +``` normal: (distribution|number, distribution|number) => distribution normal: (dict<{p5: distribution|number, p95: distribution|number}>) => distribution normal: (dict<{mean: distribution|number, stdev: distribution|number}>) => distribution @@ -41,9 +39,7 @@ normal({ mean: uniform(5, 9), stdev: 3 }) ### lognormal -**Definitions** - -```javascript +``` lognormal: (distribution|number, distribution|number) => distribution lognormal: (dict<{p5: distribution|number, p95: distribution|number}>) => distribution lognormal: (dict<{mean: distribution|number, stdev: distribution|number}>) => distribution @@ -59,9 +55,7 @@ lognormal({ mean: 5, stdev: 2 }) ### uniform -**Definitions** - -```javascript +``` uniform: (distribution|number, distribution|number) => distribution ``` @@ -73,9 +67,7 @@ uniform(10, 12) ### beta -**Definitions** - -```javascript +``` beta: (distribution|number, distribution|number) => distribution ``` @@ -87,9 +79,7 @@ beta(20, 25) ### cauchy -**Definitions** - -```javascript +``` cauchy: (distribution|number, distribution|number) => distribution ``` @@ -101,8 +91,6 @@ cauchy(5, 1) ### gamma -**Definitions** - ```javascript gamma: (distribution|number, distribution|number) => distribution ``` @@ -115,9 +103,7 @@ gamma(5, 1) ### Logistic -**Definitions** - -```javascript +``` logistic: (distribution|number, distribution|number) => distribution ``` @@ -129,9 +115,7 @@ gamma(5, 1) ### exponential -**Definitions** - -```javascript +``` exponential: (distribution|number) => distribution ``` @@ -143,9 +127,7 @@ exponential(2) ### bernoulli -**Definitions** - -```javascript +``` bernoulli: (distribution|number) => distribution ``` @@ -157,8 +139,6 @@ bernoulli(0.5) ### triangular -**Definitions** - ```javascript triangular: (number, number, number) => distribution ``` @@ -177,7 +157,7 @@ If both values are above zero, a `lognormal` distribution is used. If not, a `no ``To`` is an alias for ``credibleIntervalToDistribution``. However, because of its frequent use, it is recommended to use the shorter name. -```javascript +``` to: (distribution|number, distribution|number) => distribution credibleIntervalToDistribution(distribution|number, distribution|number) => distribution ``` @@ -193,7 +173,7 @@ to(5,10) ### mixture -```javascript +``` mixture: (...distributionLike, weights?:list) => distribution mixture: (list, weights?:list) => distribution ``` @@ -212,8 +192,8 @@ mx([normal(5, 1), normal(10, 1)], [0.3, 0.7]) One random sample from the distribution -```javascript -sample(distribution) => number +``` +sample: (distribution) => number ``` **Examples** @@ -226,7 +206,7 @@ sample(normal(5, 2)) N random samples from the distribution -```javascript +``` sampleN: (distribution, number) => list ``` @@ -240,7 +220,7 @@ sampleN(normal(5, 2), 100) The distribution mean -```javascript +``` mean: (distribution) => number ``` @@ -254,7 +234,7 @@ mean(normal(5, 2)) Standard deviation. Only works now on sample set distributions (so converts other distributions into sample set in order to calculate.) -```javascript +``` stdev: (distribution) => number ``` @@ -262,19 +242,19 @@ stdev: (distribution) => number Variance. Similar to stdev, only works now on sample set distributions. -```javascript +``` variance: (distribution) => number ``` ### mode -```javascript +``` mode: (distribution) => number ``` ### cdf -```javascript +``` cdf: (distribution, number) => number ``` @@ -286,7 +266,7 @@ cdf(normal(5, 2), 3) ### pdf -```javascript +``` pdf: (distribution, number) => number ``` @@ -298,7 +278,7 @@ pdf(normal(5, 2), 3) ### quantile -```javascript +``` quantile: (distribution, number) => number ``` @@ -310,9 +290,11 @@ quantile(normal(5, 2), 0.5) ### toPointSet +**TODO: Will soon be called "PointSet.make"** + Converts a distribution to the pointSet format -```javascript +``` toPointSet: (distribution) => pointSetDistribution ``` @@ -323,10 +305,11 @@ toPointSet(normal(5, 2)) ``` ### toSampleSet +**TODO: Will soon be called "SampleSet.make"** Converts a distribution to the sampleSet format, with n samples -```javascript +``` toSampleSet: (distribution, number) => sampleSetDistribution ``` @@ -340,7 +323,7 @@ toSampleSet(normal(5, 2), 1000) Truncates the left side of a distribution. Returns either a pointSet distribution or a symbolic distribution. -```javascript +``` truncateLeft: (distribution, l => number) => distribution ``` @@ -354,7 +337,7 @@ truncateLeft(normal(5, 2), 3) Truncates the right side of a distribution. Returns either a pointSet distribution or a symbolic distribution. -```javascript +``` truncateRight: (distribution, r => number) => distribution ``` @@ -368,7 +351,7 @@ truncateLeft(normal(5, 2), 6) [Kullback–Leibler divergence](https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence) between two distributions. -```javascript +``` klDivergence: (distribution, distribution) => number ``` @@ -382,7 +365,7 @@ klDivergence(normal(5, 2), normal(5, 4)) // returns 0.57 ### toString -```javascript +``` toString: (distribution) => string ``` @@ -396,7 +379,7 @@ toString(normal(5, 2)) Produce a sparkline of length n -```javascript +``` toSparkline: (distribution, n = 20) => string ``` @@ -410,7 +393,7 @@ toSparkline(normal(5, 2), 10) Prints the value of the distribution to the Javascript console, then returns the distribution. -```javascript +``` inspect: (distribution) => distribution ``` @@ -426,7 +409,7 @@ inspect(normal(5, 2)) Normalize a distribution. This means scaling it appropriately so that it's cumulative sum is equal to 1. -```javascript +``` normalize: (distribution) => distribution ``` @@ -440,7 +423,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 +``` isNormalized: (distribution) => bool ``` @@ -454,7 +437,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 +``` integralSum: (distribution) => number ``` @@ -476,10 +459,12 @@ pointMass(5 + 10) == pointMass(5) + pointMass(10) ### add -```javascript +``` add: (distributionLike, distributionLike) => distribution ``` +**Examples** + ```javascript normal(0,1) + normal(1,3) // returns normal(1, 3.16...) add(normal(0,1), normal(1,3)) // returns normal(1, 3.16...) @@ -488,68 +473,72 @@ add(normal(0,1), normal(1,3)) // returns normal(1, 3.16...) ### sum **Todo: Not yet implemented for distributions** -```javascript +``` sum: (list) => distribution ``` +**Examples** + ```javascript sum([normal(0,1), normal(1,3), uniform(10,1)]) ``` ### multiply -```javascript +``` multiply: (distributionLike, distributionLike) => distribution ``` ### product -```javascript +``` product: (list) => distribution ``` ### subtract -```javascript +``` subtract: (distributionLike, distributionLike) => distribution ``` ### divide -```javascript +``` divide: (distributionLike, distributionLike) => distribution ``` ### pow -```javascript +``` pow: (distributionLike, distributionLike) => distribution ``` ### exp -```javascript +``` exp: (distributionLike, distributionLike) => distribution ``` ### log -```javascript +``` log: (distributionLike, distributionLike) => distribution ``` ### log10 -```javascript +``` log10: (distributionLike, distributionLike) => distribution ``` ### unaryMinus -```javascript +``` unaryMinus: (distribution) => distribution ``` +**Examples** + ```javascript -(normal(5,2)) // same as normal(-5, 2) unaryMinus(normal(5,2)) // same as normal(-5, 2) @@ -559,37 +548,37 @@ unaryMinus(normal(5,2)) // same as normal(-5, 2) ### dotAdd -```javascript +``` dotAdd: (distributionLike, distributionLike) => distribution ``` ### dotMultiply -```javascript +``` dotMultiply: (distributionLike, distributionLike) => distribution ``` ### dotSubtract -```javascript +``` dotSubtract: (distributionLike, distributionLike) => distribution ``` ### dotDivide -```javascript +``` dotDivide: (distributionLike, distributionLike) => distribution ``` ### dotPow -```javascript +``` dotPow: (distributionLike, distributionLike) => distribution ``` ### dotExp -```javascript +``` dotExp: (distributionLike, distributionLike) => distribution ``` @@ -597,31 +586,31 @@ dotExp: (distributionLike, distributionLike) => distribution ### scaleMultiply -```javascript +``` scaleMultiply: (distributionLike, number) => distribution ``` ### scalePow -```javascript +``` scalePow: (distributionLike, number) => distribution ``` ### scaleExp -```javascript +``` scaleExp: (distributionLike, number) => distribution ``` ### scaleLog -```javascript +``` scaleLog: (distributionLike, number) => distribution ``` ### scaleLog10 -```javascript +``` scaleLog10: (distributionLike, number) => distribution ``` @@ -631,7 +620,7 @@ scaleLog10: (distributionLike, number) => distribution 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 +``` declareFn: (dict<{fn: lambda, inputs: array>}>) => declaration ``` diff --git a/packages/website/docs/Api/DistPointSet.md b/packages/website/docs/Api/DistPointSet.md index 6e2eea26..eb3f8b93 100644 --- a/packages/website/docs/Api/DistPointSet.md +++ b/packages/website/docs/Api/DistPointSet.md @@ -41,7 +41,7 @@ PointSet.makeDiscrete: (list<{x: number, y: number}>) => pointSetDist ``` ```javascript -toDiscretePointSet([ +PointSet.makeDiscrete([ { x: 0, y: 0.1 }, { x: 1, y: 0.2 }, { x: 2, y: 0.15 },