functions reference is almost done
This commit is contained in:
parent
76a0f254ea
commit
9cdffc309b
2
packages/website/.prettierignore
Normal file
2
packages/website/.prettierignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
.docusaurus
|
||||
build
|
|
@ -19,6 +19,7 @@ and standard deviation.
|
|||
<SquiggleEditor initialSquiggleString="normal(5, 1)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `sd > 0`
|
||||
|
||||
## Uniform distribution
|
||||
|
@ -29,6 +30,7 @@ two given numbers.
|
|||
<SquiggleEditor initialSquiggleString="uniform(3, 7)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `low < high`
|
||||
|
||||
## Lognormal distribution
|
||||
|
@ -45,12 +47,14 @@ this convinience as lognormal distributions are commonly used in practice.
|
|||
<SquiggleEditor initialSquiggleString="2 to 10" />
|
||||
|
||||
### Future feature:
|
||||
|
||||
Furthermore, it's also possible to create a lognormal from it's actual mean
|
||||
and standard deviation, using `lognormalFromMeanAndStdDev`.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="lognormalFromMeanAndStdDev(20, 10)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `sigma > 0`
|
||||
- In `x to y` notation, `x < y`
|
||||
|
||||
|
@ -61,6 +65,7 @@ The `beta(a, b)` function creates a beta distribution with parameters `a` and `b
|
|||
<SquiggleEditor initialSquiggleString="beta(20, 20)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `a > 0`
|
||||
- `b > 0`
|
||||
- Empirically, we have noticed that numerical instability arises when `a < 1` or `b < 1`
|
||||
|
@ -73,6 +78,7 @@ rate.
|
|||
<SquiggleEditor initialSquiggleString="exponential(1)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `rate > 0`
|
||||
|
||||
## Triangular distribution
|
||||
|
@ -81,6 +87,7 @@ The `triangular(a,b,c)` function creates a triangular distribution with lower
|
|||
bound `a`, mode `b` and upper bound `c`.
|
||||
|
||||
### Validity
|
||||
|
||||
- `a < b < c`
|
||||
|
||||
<SquiggleEditor initialSquiggleString="triangular(1, 2, 4)" />
|
||||
|
@ -113,7 +120,9 @@ As well as mixed distributions:
|
|||
An alias of `mx` is `mixture`
|
||||
|
||||
### Validity
|
||||
|
||||
Using javascript's variable arguments notation, consider `mx(...dists, weights)`:
|
||||
|
||||
- `dists.length == weights.length`
|
||||
|
||||
## Addition (horizontal right shift)
|
||||
|
@ -143,6 +152,7 @@ Using javascript's variable arguments notation, consider `mx(...dists, weights)`
|
|||
<SquiggleEditor initialSquiggleString="dist = beta(1,2); log10(dist)">
|
||||
|
||||
### Validity
|
||||
|
||||
- See [the current discourse](https://github.com/quantified-uncertainty/squiggle/issues/304)
|
||||
|
||||
# Standard functions on distributions
|
||||
|
@ -155,6 +165,7 @@ given point x.
|
|||
<SquiggleEditor initialSquiggleString="pdf(normal(0,1),0)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `x` must be a scalar
|
||||
- `dist` must be a distribution
|
||||
|
||||
|
@ -166,6 +177,7 @@ or all values lower than x. It is the inverse of `inv`.
|
|||
<SquiggleEditor initialSquiggleString="cdf(normal(0,1),0)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `x` must be a scalar
|
||||
- `dist` must be a distribution
|
||||
|
||||
|
@ -177,6 +189,7 @@ lower than x is equal to prob. It is the inverse of `cdf`.
|
|||
<SquiggleEditor initialSquiggleString="inv(normal(0,1),0.5)" />
|
||||
|
||||
### Validity
|
||||
|
||||
- `prob` must be a scalar (please only put it in `(0,1)`)
|
||||
- `dist` must be a distribution
|
||||
|
||||
|
@ -199,14 +212,14 @@ Some distribution operations (like horizontal shift) return an unnormalized dist
|
|||
We provide a `normalize` function
|
||||
|
||||
<SquiggleEditor initialSquiggleString="normalize((1e-1 to 1e0) + triangular(1e-1, 1e0, 1e1))" />
|
||||
### Valdity
|
||||
- Input to `normalize` must be a dist
|
||||
### Valdity - Input to `normalize` must be a dist
|
||||
|
||||
We provide a predicate `isNormalized`, for when we have simple control flow
|
||||
|
||||
<SquiggleEditor initialSquiggleString="isNormalized((1e-1 to 1e0) * triangular(1e-1, 1e0, 1e1))" />
|
||||
|
||||
### Validity
|
||||
|
||||
- Input to `isNormalized` must be a dist
|
||||
|
||||
# Convert any distribution to a sample set distribution
|
||||
|
@ -221,3 +234,24 @@ And binary when you provide a number of samples (truncated)
|
|||
|
||||
<SquiggleEditor initialSquiggleString="toSampleSet(1e-1 to 1e0, 1e2)" />
|
||||
|
||||
# `inspect`
|
||||
|
||||
You may like to debug by right clicking your browser and using the _inspect_ functionality on the webpage, and viewing the _console_ tab. Then, wrap your squiggle output with `inspect` to log an internal representation.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="inspect(toSampleSet(1e-1 to 1e0, 1e2))" />
|
||||
|
||||
Save for a logging side effect, `inspect` does nothing to input and returns it.
|
||||
|
||||
# Truncate
|
||||
|
||||
You can cut off from the left
|
||||
|
||||
<SquiggleEditor initialSquiggleString="truncateLeft(1e-1 to 1e0, 5e-1)" />
|
||||
|
||||
You can cut off from the right
|
||||
|
||||
<SquiggleEditor initialSquiggleString="truncateLeft(1e-1 to 1e0, 1e1)" />
|
||||
|
||||
You can cut off from both sides
|
||||
|
||||
<SquiggleEditor initialSquiggleString="truncate(1e-1 to 1e0, 5e-1, 1e1))" />
|
||||
|
|
|
@ -127,11 +127,13 @@ TODO
|
|||
With $\forall dist, pdf := x \mapsto \texttt{pdf}(dist, x) \land cdf := x \mapsto \texttt{cdf}(dist, x) \land inv := p \mapsto \texttt{inv}(dist, p)$,
|
||||
|
||||
## `cdf` and `inv` are inverses
|
||||
|
||||
$$
|
||||
\forall x \in (0,1), cdf(inv(x)) = x \land \forall x \in \texttt{dom}(cdf), x = inv(cdf(x))
|
||||
$$
|
||||
|
||||
## The codomain of `cdf` equals the open interval `(0,1)` equals the codomain of `pdf`
|
||||
|
||||
$$
|
||||
\texttt{cod}(cdf) = (0,1) = \texttt{cod}(pdf)
|
||||
$$
|
||||
|
|
Loading…
Reference in New Issue
Block a user