Merge branch 'develop' into log-and-power-bug-fixes
This commit is contained in:
commit
9637d17099
7
.github/workflows/codeql-analysis.yml
vendored
7
.github/workflows/codeql-analysis.yml
vendored
|
@ -18,13 +18,6 @@ on:
|
|||
- production
|
||||
- staging
|
||||
- develop
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches:
|
||||
- master
|
||||
- production
|
||||
- staging
|
||||
- develop
|
||||
schedule:
|
||||
- cron: "42 19 * * 0"
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"extends": "@parcel/config-default",
|
||||
"transformers": {
|
||||
"*.res": ["@parcel/transformer-raw"]
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ The playground depends on the components library which then depends on the langu
|
|||
|
||||
# Develop
|
||||
|
||||
For any project in the repo, begin by running `yarn` in the top level (TODO: is this true?)
|
||||
For any project in the repo, begin by running `yarn` in the top level
|
||||
|
||||
```sh
|
||||
yarn
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
"@quri/squiggle-lang": "0.2.2",
|
||||
"@react-hook/size": "^2.1.2",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.0.1",
|
||||
"@testing-library/user-event": "^14.0.4",
|
||||
"@testing-library/react": "^13.1.1",
|
||||
"@testing-library/user-event": "^14.1.1",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@types/lodash": "^4.14.181",
|
||||
"@types/node": "^17.0.24",
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/node": "^17.0.25",
|
||||
"@types/react": "^18.0.3",
|
||||
"@types/react-dom": "^18.0.1",
|
||||
"antd": "^4.19.3",
|
||||
|
|
|
@ -2,3 +2,5 @@ dist
|
|||
lib
|
||||
*.bs.js
|
||||
*.gen.tsx
|
||||
.nyc_output/
|
||||
coverage/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"@glennsl/bs-json": "^5.0.2",
|
||||
"jstat": "^1.9.5",
|
||||
"lodash": "4.17.21",
|
||||
"mathjs": "10.4.3",
|
||||
"mathjs": "10.5.0",
|
||||
"pdfast": "^0.2.0",
|
||||
"rationale": "0.2.0",
|
||||
"rescript": "^9.1.4",
|
||||
|
|
|
@ -86,7 +86,9 @@ module Exponential = {
|
|||
|
||||
module Cauchy = {
|
||||
type t = cauchy
|
||||
let make = (local, scale): symbolicDist => #Cauchy({local: local, scale: scale})
|
||||
let make = (local, scale): result<symbolicDist, string> => Ok(
|
||||
#Cauchy({local: local, scale: scale}),
|
||||
)
|
||||
let pdf = (x, t: t) => Jstat.Cauchy.pdf(x, t.local, t.scale)
|
||||
let cdf = (x, t: t) => Jstat.Cauchy.cdf(x, t.local, t.scale)
|
||||
let inv = (p, t: t) => Jstat.Cauchy.inv(p, t.local, t.scale)
|
||||
|
|
|
@ -44,7 +44,7 @@ let defaultBindings: T.bindings = Belt.Map.String.empty
|
|||
/*
|
||||
Recursively evaluate/reduce the expression (Lisp AST)
|
||||
*/
|
||||
let rec reduceExpression = (expression: t, bindings: T.bindings): result<expressionValue, 'e> => {
|
||||
let reduceExpression = (expression: t, bindings: T.bindings): result<expressionValue, 'e> => {
|
||||
/*
|
||||
After reducing each level of expression(Lisp AST), we have a value list to evaluate
|
||||
*/
|
||||
|
@ -135,6 +135,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result<express
|
|||
)
|
||||
racc->Result.flatMap(acc => acc->doMacroCall(bindings))
|
||||
}
|
||||
| T.EBindings(bindings) => T.EBindings(bindings)->Ok
|
||||
}
|
||||
|
||||
let rec reduceExpandedExpression = (expression: t): result<expressionValue, 'e> =>
|
||||
|
@ -155,6 +156,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result<express
|
|||
)
|
||||
racc->Result.flatMap(acc => acc->reduceValueList)
|
||||
}
|
||||
| T.EBindings(bindings) => RETodo("Cannot return bindings")->Error
|
||||
}
|
||||
|
||||
let rExpandedExpression: result<t, 'e> = expression->seekMacros(bindings)
|
||||
|
|
|
@ -149,6 +149,7 @@ module SymbolicConstructors = {
|
|||
| "uniform" => Ok(SymbolicDist.Uniform.make)
|
||||
| "beta" => Ok(SymbolicDist.Beta.make)
|
||||
| "lognormal" => Ok(SymbolicDist.Lognormal.make)
|
||||
| "cauchy" => Ok(SymbolicDist.Cauchy.make)
|
||||
| "to" => Ok(SymbolicDist.From90thPercentile.make)
|
||||
| _ => Error("Unreachable state")
|
||||
}
|
||||
|
@ -182,7 +183,7 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option<
|
|||
->E.R.bind(r => r(f1))
|
||||
->SymbolicConstructors.symbolicResultToOutput
|
||||
| (
|
||||
("normal" | "uniform" | "beta" | "lognormal" | "to") as fnName,
|
||||
("normal" | "uniform" | "beta" | "lognormal" | "cauchy" | "to") as fnName,
|
||||
[EvNumber(f1), EvNumber(f2)],
|
||||
) =>
|
||||
SymbolicConstructors.twoFloat(fnName)
|
||||
|
|
2
packages/website/.prettierignore
Normal file
2
packages/website/.prettierignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
.docusaurus
|
||||
build
|
|
@ -1,12 +1,15 @@
|
|||
---
|
||||
title: "Functions Reference"
|
||||
sidebar_position: 7
|
||||
---
|
||||
|
||||
import { SquiggleEditor } from "../../src/components/SquiggleEditor";
|
||||
|
||||
# Squiggle Functions Reference
|
||||
_The source of truth for this document is [this file of code](https://github.com/quantified-uncertainty/squiggle/blob/develop/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res)_
|
||||
|
||||
## Distributions
|
||||
## Inventory distributions
|
||||
|
||||
We provide starter distributions, computed symbolically.
|
||||
|
||||
### Normal distribution
|
||||
|
||||
|
@ -15,6 +18,10 @@ and standard deviation.
|
|||
|
||||
<SquiggleEditor initialSquiggleString="normal(5, 1)" />
|
||||
|
||||
#### Validity
|
||||
|
||||
- `sd > 0`
|
||||
|
||||
### Uniform distribution
|
||||
|
||||
The `uniform(low, high)` function creates a uniform distribution between the
|
||||
|
@ -22,86 +29,281 @@ two given numbers.
|
|||
|
||||
<SquiggleEditor initialSquiggleString="uniform(3, 7)" />
|
||||
|
||||
#### Validity
|
||||
|
||||
- `low < high`
|
||||
|
||||
### Lognormal distribution
|
||||
|
||||
The `lognormal(mu, sigma)` returns the log of a normal distribution with parameters
|
||||
mu and sigma. The log of lognormal(mu, sigma) is a normal distribution with parameters
|
||||
mean mu and standard deviation sigma.
|
||||
`mu` and `sigma`. The log of `lognormal(mu, sigma)` is a normal distribution with mean `mu` and standard deviation `sigma`.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="lognormal(0, 0.7)" />
|
||||
|
||||
An alternative format is also available. The "to" notation creates a lognormal
|
||||
An alternative format is also available. The `to` notation creates a lognormal
|
||||
distribution with a 90% confidence interval between the two numbers. We add
|
||||
this convinience as lognormal distributions are commonly used in practice.
|
||||
this convenience 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`.
|
||||
|
||||
TODO: interpreter/parser doesn't provide this in current `develop` branch
|
||||
|
||||
<SquiggleEditor initialSquiggleString="lognormalFromMeanAndStdDev(20, 10)" />
|
||||
|
||||
#### Validity
|
||||
|
||||
- `sigma > 0`
|
||||
- In `x to y` notation, `x < y`
|
||||
|
||||
### Beta distribution
|
||||
|
||||
The `beta(a, b)` function creates a beta distribution with parameters a and b:
|
||||
The `beta(a, b)` function creates a beta distribution with parameters `a` and `b`:
|
||||
|
||||
<SquiggleEditor initialSquiggleString="beta(20, 20)" />
|
||||
<SquiggleEditor initialSquiggleString="beta(10, 20)" />
|
||||
|
||||
#### Validity
|
||||
|
||||
- `a > 0`
|
||||
- `b > 0`
|
||||
- Empirically, we have noticed that numerical instability arises when `a < 1` or `b < 1`
|
||||
|
||||
### Exponential distribution
|
||||
|
||||
The `exponential(mean)` function creates an exponential distribution with the given
|
||||
mean.
|
||||
The `exponential(rate)` function creates an exponential distribution with the given
|
||||
rate.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="exponential(1)" />
|
||||
<SquiggleEditor initialSquiggleString="exponential(1.11)" />
|
||||
|
||||
### The Triangular distribution
|
||||
#### Validity
|
||||
|
||||
- `rate > 0`
|
||||
|
||||
### Triangular distribution
|
||||
|
||||
The `triangular(a,b,c)` function creates a triangular distribution with lower
|
||||
bound a, mode b and upper bound c.
|
||||
bound `a`, mode `b` and upper bound `c`.
|
||||
|
||||
#### Validity
|
||||
|
||||
- `a < b < c`
|
||||
|
||||
<SquiggleEditor initialSquiggleString="triangular(1, 2, 4)" />
|
||||
|
||||
### Multimodal distriutions
|
||||
### Scalar (constant dist)
|
||||
|
||||
The multimodal function combines 2 or more other distributions to create a weighted
|
||||
Squiggle, when the context is right, automatically casts a float to a constant distribution.
|
||||
|
||||
## Operating on distributions
|
||||
|
||||
Here are the ways we combine distributions.
|
||||
|
||||
### Mixture of distributions
|
||||
|
||||
The `mixture` function combines 2 or more other distributions to create a weighted
|
||||
combination of the two. The first positional arguments represent the distributions
|
||||
to be combined, and the last argument is how much to weigh every distribution in the
|
||||
combination.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="mx(uniform(0,1), normal(1,1), [0.5, 0.5])" />
|
||||
<SquiggleEditor initialSquiggleString="mixture(uniform(0,1), normal(1,1), [0.5, 0.5])" />
|
||||
|
||||
It's possible to create discrete distributions using this method.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="mx(0, 1, [0.2,0.8])" />
|
||||
<SquiggleEditor initialSquiggleString="mixture(0, 1, [0.2,0.8])" />
|
||||
|
||||
As well as mixed distributions:
|
||||
|
||||
<SquiggleEditor initialSquiggleString="mx(3, 8, 1 to 10, [0.2, 0.3, 0.5])" />
|
||||
<SquiggleEditor initialSquiggleString="mixture(3, 8, 1 to 10, [0.2, 0.3, 0.5])" />
|
||||
|
||||
## Other Functions
|
||||
An alias of `mixture` is `mx`
|
||||
|
||||
### PDF of a distribution
|
||||
#### Validity
|
||||
|
||||
The `pdf(distribution, x)` function returns the density of a distribution at the
|
||||
Using javascript's variable arguments notation, consider `mx(...dists, weights)`:
|
||||
|
||||
- `dists.length == weights.length`
|
||||
|
||||
### Addition
|
||||
|
||||
A horizontal right shift
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 + dist2`}
|
||||
/>
|
||||
|
||||
### Subtraction
|
||||
|
||||
A horizontal left shift
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 - dist2`}
|
||||
/>
|
||||
|
||||
### Multiplication
|
||||
|
||||
TODO: provide intuition pump for the semantics
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 * dist2`}
|
||||
/>
|
||||
|
||||
We also provide concatenation of two distributions as a syntax sugar for `*`
|
||||
|
||||
<SquiggleEditor initialSquiggleString="(0.1 to 1) triangular(1,2,3)" />
|
||||
|
||||
### Division
|
||||
|
||||
TODO: provide intuition pump for the semantics
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 / dist2`}
|
||||
/>
|
||||
|
||||
### Exponentiation
|
||||
|
||||
TODO: provide intuition pump for the semantics
|
||||
|
||||
<SquiggleEditor initialSquiggleString={`(0.1 to 1) ^ beta(2, 3)`} />
|
||||
|
||||
### Taking the base `e` exponential
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist = triangular(1,2,3)
|
||||
exp(dist)`}
|
||||
/>
|
||||
|
||||
### Taking logarithms
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist = triangular(1,2,3)
|
||||
log(dist)`}
|
||||
/>
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist = beta(1,2)
|
||||
log10(dist)`}
|
||||
/>
|
||||
|
||||
Base `x`
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`x = 2
|
||||
dist = beta(2,3)
|
||||
log(dist, x)`}
|
||||
/>
|
||||
|
||||
#### Validity
|
||||
|
||||
- `x` must be a scalar
|
||||
- See [the current discourse](https://github.com/quantified-uncertainty/squiggle/issues/304)
|
||||
|
||||
### Pointwise addition
|
||||
|
||||
**Pointwise operations are done with `PointSetDist` internals rather than `SampleSetDist` internals**.
|
||||
|
||||
TODO: this isn't in the new interpreter/parser yet.
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 .+ dist2`}
|
||||
/>
|
||||
|
||||
### Pointwise subtraction
|
||||
|
||||
TODO: this isn't in the new interpreter/parser yet.
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 .- dist2`}
|
||||
/>
|
||||
|
||||
### Pointwise multiplication
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 .* dist2`}
|
||||
/>
|
||||
|
||||
### Pointwise division
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 ./ dist2`}
|
||||
/>
|
||||
|
||||
### Pointwise exponentiation
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dist1 .^ dist2`}
|
||||
/>
|
||||
|
||||
### Pointwise logarithm
|
||||
|
||||
TODO: write about the semantics and the case handling re scalar vs. dist and log base.
|
||||
|
||||
<SquiggleEditor
|
||||
initialSquiggleString={`dist1 = 1 to 10
|
||||
dist2 = triangular(1,2,3)
|
||||
dotLog(dist1, dist2)`}
|
||||
/>
|
||||
|
||||
## Standard functions on distributions
|
||||
|
||||
### Probability density function
|
||||
|
||||
The `pdf(dist, x)` function returns the density of a distribution at the
|
||||
given point x.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="pdf(normal(0,1),0)" />
|
||||
|
||||
### Inverse of a distribution
|
||||
#### Validity
|
||||
|
||||
The `inv(distribution, prob)` gives the value x or which the probability for all values
|
||||
lower than x is equal to prob. It is the inverse of `cdf`.
|
||||
- `x` must be a scalar
|
||||
- `dist` must be a distribution
|
||||
|
||||
<SquiggleEditor initialSquiggleString="inv(normal(0,1),0.5)" />
|
||||
### Cumulative density function
|
||||
|
||||
### CDF of a distribution
|
||||
|
||||
The `cdf(distribution,x)` gives the cumulative probability of the distribution
|
||||
The `cdf(dist, x)` gives the cumulative probability of the distribution
|
||||
or all values lower than x. It is the inverse of `inv`.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="cdf(normal(0,1),0)" />
|
||||
|
||||
### Mean of a distribution
|
||||
#### Validity
|
||||
|
||||
- `x` must be a scalar
|
||||
- `dist` must be a distribution
|
||||
|
||||
### Inverse CDF
|
||||
|
||||
The `inv(dist, prob)` gives the value x or which the probability for all values
|
||||
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
|
||||
|
||||
### Mean
|
||||
|
||||
The `mean(distribution)` function gives the mean (expected value) of a distribution.
|
||||
|
||||
|
@ -112,3 +314,55 @@ The `mean(distribution)` function gives the mean (expected value) of a distribut
|
|||
The `sample(distribution)` samples a given distribution.
|
||||
|
||||
<SquiggleEditor initialSquiggleString="sample(normal(0, 10))" />
|
||||
|
||||
## Normalization
|
||||
|
||||
Some distribution operations (like horizontal shift) return an unnormalized distriibution.
|
||||
|
||||
We provide a `normalize` function
|
||||
|
||||
<SquiggleEditor initialSquiggleString="normalize((0.1 to 1) + triangular(0.1, 1, 10))" />
|
||||
|
||||
#### Validity - Input to `normalize` must be a dist
|
||||
|
||||
We provide a predicate `isNormalized`, for when we have simple control flow
|
||||
|
||||
<SquiggleEditor initialSquiggleString="isNormalized((0.1 to 1) * triangular(0.1, 1, 10))" />
|
||||
|
||||
#### Validity
|
||||
|
||||
- Input to `isNormalized` must be a dist
|
||||
|
||||
## Convert any distribution to a sample set distribution
|
||||
|
||||
`toSampleSet` has two signatures
|
||||
|
||||
It is unary when you use an internal hardcoded number of samples
|
||||
|
||||
<SquiggleEditor initialSquiggleString="toSampleSet(0.1 to 1)" />
|
||||
|
||||
And binary when you provide a number of samples (floored)
|
||||
|
||||
<SquiggleEditor initialSquiggleString="toSampleSet(0.1 to 1, 100)" />
|
||||
|
||||
## `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(0.1 to 1, 100))" />
|
||||
|
||||
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(0.1 to 1, 0.5)" />
|
||||
|
||||
You can cut off from the right
|
||||
|
||||
<SquiggleEditor initialSquiggleString="truncateRight(0.1 to 1, 10)" />
|
||||
|
||||
You can cut off from both sides
|
||||
|
||||
<SquiggleEditor initialSquiggleString="truncate(0.1 to 1, 0.5, 1.5)" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Statistical properties of algebraic combinations of distributions for property testing.
|
||||
title: Invariants of Probability Distributions
|
||||
urlcolor: blue
|
||||
author:
|
||||
- Nuño Sempere
|
||||
|
@ -7,13 +7,17 @@ author:
|
|||
abstract: This document outlines some properties about algebraic combinations of distributions. It is meant to facilitate property tests for [Squiggle](https://squiggle-language.com/), an estimation language for forecasters. So far, we are focusing on the means, the standard deviation and the shape of the pdfs.
|
||||
---
|
||||
|
||||
Invariants to check with property tests.
|
||||
|
||||
_This document right now is normative and aspirational, not a description of the testing that's currently done_.
|
||||
|
||||
## Algebraic combinations
|
||||
|
||||
The academic keyword to search for in relation to this document is "[algebra of random variables](https://wikiless.org/wiki/Algebra_of_random_variables?lang=en)". Squiggle doesn't yet support getting the standard deviation, denoted by $\sigma$, but such support could yet be added.
|
||||
|
||||
## Means and standard deviations
|
||||
### Means and standard deviations
|
||||
|
||||
### Sums
|
||||
#### Sums
|
||||
|
||||
$$
|
||||
mean(f+g) = mean(f) + mean(g)
|
||||
|
@ -29,7 +33,7 @@ $$
|
|||
mean(normal(a,b) + normal(c,d)) = mean(normal(a+c, \sqrt{b^2 + d^2}))
|
||||
$$
|
||||
|
||||
### Subtractions
|
||||
#### Subtractions
|
||||
|
||||
$$
|
||||
mean(f-g) = mean(f) - mean(g)
|
||||
|
@ -39,7 +43,7 @@ $$
|
|||
\sigma(f-g) = \sqrt{\sigma(f)^2 + \sigma(g)^2}
|
||||
$$
|
||||
|
||||
### Multiplications
|
||||
#### Multiplications
|
||||
|
||||
$$
|
||||
mean(f \cdot g) = mean(f) \cdot mean(g)
|
||||
|
@ -49,15 +53,15 @@ $$
|
|||
\sigma(f \cdot g) = \sqrt{ (\sigma(f)^2 + mean(f)) \cdot (\sigma(g)^2 + mean(g)) - (mean(f) \cdot mean(g))^2}
|
||||
$$
|
||||
|
||||
### Divisions
|
||||
#### Divisions
|
||||
|
||||
Divisions are tricky, and in general we don't have good expressions to characterize properties of ratios. In particular, the ratio of two normals is a Cauchy distribution, which doesn't have to have a mean.
|
||||
|
||||
## Probability density functions (pdfs)
|
||||
### Probability density functions (pdfs)
|
||||
|
||||
Specifying the pdf of the sum/multiplication/... of distributions as a function of the pdfs of the individual arguments can still be done. But it requires integration. My sense is that this is still doable, and I (Nuño) provide some _pseudocode_ to do this.
|
||||
|
||||
### Sums
|
||||
#### Sums
|
||||
|
||||
Let $f, g$ be two independently distributed functions. Then, the pdf of their sum, evaluated at a point $z$, expressed as $(f + g)(z)$, is given by:
|
||||
|
||||
|
@ -110,15 +114,31 @@ let pdfOfSum = (pdf1, pdf2, cdf1, cdf2, z) => {
|
|||
};
|
||||
```
|
||||
|
||||
## Cumulative density functions
|
||||
### Cumulative density functions
|
||||
|
||||
TODO
|
||||
|
||||
## Inverse cumulative density functions
|
||||
### Inverse cumulative density functions
|
||||
|
||||
TODO
|
||||
|
||||
# To do:
|
||||
## `pdf`, `cdf`, and `inv`
|
||||
|
||||
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)
|
||||
$$
|
||||
|
||||
## To do:
|
||||
|
||||
- Provide sources or derivations, useful as this document becomes more complicated
|
||||
- Provide definitions for the probability density function, exponential, inverse, log, etc.
|
||||
|
|
|
@ -49,7 +49,7 @@ const config = {
|
|||
sidebarPath: require.resolve("./sidebars.js"),
|
||||
// Please change this to your repo.
|
||||
editUrl:
|
||||
"https://github.com/quantified-uncertainty/squiggle/tree/master/packages/website/",
|
||||
"https://github.com/quantified-uncertainty/squiggle/tree/develop/packages/website/",
|
||||
remarkPlugins: [math],
|
||||
rehypePlugins: [katex],
|
||||
},
|
||||
|
@ -57,7 +57,7 @@ const config = {
|
|||
showReadingTime: true,
|
||||
// Please change this to your repo.
|
||||
editUrl:
|
||||
"https://github.com/quantified-uncertainty/squiggle/tree/master/packages/website/",
|
||||
"https://github.com/quantified-uncertainty/squiggle/tree/develop/packages/website/",
|
||||
},
|
||||
theme: {
|
||||
customCss: require.resolve("./src/css/custom.css"),
|
||||
|
@ -73,7 +73,7 @@ const config = {
|
|||
title: "Squiggle",
|
||||
logo: {
|
||||
alt: "Squiggle Logo",
|
||||
src: "img/logo.svg",
|
||||
src: "img/quri-logo.png",
|
||||
},
|
||||
items: [
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ const config = {
|
|||
{ to: "/blog", label: "Blog", position: "left" },
|
||||
{ to: "/playground", label: "Playground", position: "left" },
|
||||
{
|
||||
href: "https://github.com/QURIresearch/squiggle",
|
||||
href: "https://github.com/quantified-uncertainty/squiggle",
|
||||
label: "GitHub",
|
||||
position: "right",
|
||||
},
|
||||
|
@ -103,7 +103,7 @@ const config = {
|
|||
},
|
||||
{
|
||||
label: "GitHub",
|
||||
href: "https://github.com/QURIresearch/squiggle",
|
||||
href: "https://github.com/quantified-uncertainty/squiggle",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -22,10 +22,7 @@ function HomepageHeader() {
|
|||
export default function Home() {
|
||||
const { siteConfig } = useDocusaurusContext();
|
||||
return (
|
||||
<Layout
|
||||
title={`Hello from ${siteConfig.title}`}
|
||||
description="Description will go into a meta tag in <head />"
|
||||
>
|
||||
<Layout title={`${siteConfig.title}`} description="An estimation language">
|
||||
<HomepageHeader />
|
||||
<main>
|
||||
<HomepageFeatures />
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 6.5 KiB |
BIN
packages/website/static/img/quri-logo.png
Normal file
BIN
packages/website/static/img/quri-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
48
yarn.lock
48
yarn.lock
|
@ -1271,7 +1271,7 @@
|
|||
core-js-pure "^3.20.2"
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.1", "@babel/runtime@^7.10.2", "@babel/runtime@^7.10.3", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.8", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.8", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
|
||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.1", "@babel/runtime@^7.10.2", "@babel/runtime@^7.10.3", "@babel/runtime@^7.10.4", "@babel/runtime@^7.11.1", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.8", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.8", "@babel/runtime@^7.17.9", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
|
||||
version "7.17.9"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.9.tgz#d19fbf802d01a8cb6cf053a64e472d42c434ba72"
|
||||
integrity sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==
|
||||
|
@ -3668,19 +3668,19 @@
|
|||
lodash "^4.17.15"
|
||||
redent "^3.0.0"
|
||||
|
||||
"@testing-library/react@^13.0.1":
|
||||
version "13.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.0.1.tgz#00d223e182923d341a9610590561fb9dd1324110"
|
||||
integrity sha512-zeHx3PohYYp+4bTJwrixQY8zSBZjWUGwYc7OhD1EpWTHS92RleApLoP72NdwaWxOrM1P1Uezt3XvGf6t2XSWPQ==
|
||||
"@testing-library/react@^13.1.1":
|
||||
version "13.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.1.1.tgz#6c1635e25acca8ca5be8ee3b19ad1391681c5846"
|
||||
integrity sha512-8mirlAa0OKaUvnqnZF6MdAh2tReYA2KtWVw1PKvaF5EcCZqgK5pl8iF+3uW90JdG5Ua2c2c2E2wtLdaug3dsVg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
"@testing-library/dom" "^8.5.0"
|
||||
"@types/react-dom" "^18.0.0"
|
||||
|
||||
"@testing-library/user-event@^14.0.4":
|
||||
version "14.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.1.0.tgz#db479c06271b72a4d41cf595ec2ad7ff078c1d72"
|
||||
integrity sha512-+CGfMXlVM+OwREHDEsfTGsXIMI+rjr3a7YBUSutq7soELht+8kQrM5k46xa/WLfHdtX/wqsDIleL6bi4i+xz0w==
|
||||
"@testing-library/user-event@^14.1.1":
|
||||
version "14.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.1.1.tgz#e1ff6118896e4b22af31e5ea2f9da956adde23d8"
|
||||
integrity sha512-XrjH/iEUqNl9lF2HX9YhPNV7Amntkcnpw0Bo1KkRzowNDcgSN9i0nm4Q8Oi5wupgdfPaJNMAWa61A+voD6Kmwg==
|
||||
|
||||
"@tootallnate/once@1":
|
||||
version "1.1.2"
|
||||
|
@ -3934,10 +3934,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/katex/-/katex-0.11.1.tgz#34de04477dcf79e2ef6c8d23b41a3d81f9ebeaf5"
|
||||
integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg==
|
||||
|
||||
"@types/lodash@^4.14.181":
|
||||
version "4.14.181"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.181.tgz#d1d3740c379fda17ab175165ba04e2d03389385d"
|
||||
integrity sha512-n3tyKthHJbkiWhDZs3DkhkCzt2MexYHXlX0td5iMplyfwketaOeKboEVBqzceH7juqvEg3q5oUoBFxSLu7zFag==
|
||||
"@types/lodash@^4.14.182":
|
||||
version "4.14.182"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.182.tgz#05301a4d5e62963227eaafe0ce04dd77c54ea5c2"
|
||||
integrity sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==
|
||||
|
||||
"@types/mdast@^3.0.0":
|
||||
version "3.0.10"
|
||||
|
@ -3964,10 +3964,10 @@
|
|||
"@types/node" "*"
|
||||
form-data "^3.0.0"
|
||||
|
||||
"@types/node@*", "@types/node@^17.0.24", "@types/node@^17.0.5":
|
||||
version "17.0.24"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.24.tgz#20ba1bf69c1b4ab405c7a01e950c4f446b05029f"
|
||||
integrity sha512-aveCYRQbgTH9Pssp1voEP7HiuWlD2jW2BO56w+bVrJn04i61yh6mRfoKO6hEYQD9vF+W8Chkwc6j1M36uPkx4g==
|
||||
"@types/node@*", "@types/node@^17.0.25", "@types/node@^17.0.5":
|
||||
version "17.0.25"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448"
|
||||
integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w==
|
||||
|
||||
"@types/node@^14.0.10":
|
||||
version "14.18.13"
|
||||
|
@ -6458,7 +6458,7 @@ commondir@^1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
|
||||
integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=
|
||||
|
||||
complex.js@^2.1.0:
|
||||
complex.js@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.1.1.tgz#0675dac8e464ec431fb2ab7d30f41d889fb25c31"
|
||||
integrity sha512-8njCHOTtFFLtegk6zQo0kkVX1rngygb/KQI6z1qZxlFI3scluC+LVTCFbrkWjBv4vvLlbQ9t88IPMC6k95VTTg==
|
||||
|
@ -11451,13 +11451,13 @@ marked@^1.2.9:
|
|||
resolved "https://registry.yarnpkg.com/marked/-/marked-1.2.9.tgz#53786f8b05d4c01a2a5a76b7d1ec9943d29d72dc"
|
||||
integrity sha512-H8lIX2SvyitGX+TRdtS06m1jHMijKN/XjfH6Ooii9fvxMlh8QdqBfBDkGUpMWH2kQNrtixjzYUa3SH8ROTgRRw==
|
||||
|
||||
mathjs@10.4.3:
|
||||
version "10.4.3"
|
||||
resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-10.4.3.tgz#456ae944204809e8e8266ff265b1ef724d03f90e"
|
||||
integrity sha512-C50lWorCOplBec9Ik5fzhHuOx4G4+mtdz3r1G2I1/r8yj+CpYFXLXNqTdg59oKmIF1tKcIzpxlC4s2dGL7f3pg==
|
||||
mathjs@10.5.0:
|
||||
version "10.5.0"
|
||||
resolved "https://registry.yarnpkg.com/mathjs/-/mathjs-10.5.0.tgz#f81d0518fe7b4b2a0b85e1125b8ecfc364fb0292"
|
||||
integrity sha512-gRnSY9psN9zgiB2QV9F4XbuX5hwjxY5Ou7qoTFWDbn2vZ3UEs+sjfK/SRg2WP30TNfZWpwlGdp8H1knFJnpFdA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.17.8"
|
||||
complex.js "^2.1.0"
|
||||
"@babel/runtime" "^7.17.9"
|
||||
complex.js "^2.1.1"
|
||||
decimal.js "^10.3.1"
|
||||
escape-latex "^1.2.0"
|
||||
fraction.js "^4.2.0"
|
||||
|
|
Loading…
Reference in New Issue
Block a user