merge: invariants docs
This commit is contained in:
commit
f3a73a9147
|
@ -7,11 +7,10 @@ nix-build
|
||||||
o result/property-tests.pdf
|
o result/property-tests.pdf
|
||||||
```
|
```
|
||||||
|
|
||||||
Without `nix`, you can install `pandoc` yourself and run
|
Without `nix`, you can install `pandoc` and `pdflatex` yourself and see `make.sh` for the rendering command.
|
||||||
```sh
|
|
||||||
pandoc -s property-tests.md -o property-tests.pdf
|
|
||||||
```
|
|
||||||
|
|
||||||
## _Details_
|
## _Details_
|
||||||
|
|
||||||
The `property-tests.pdf` document is _normative and aspirational_. It does not document tests as they exist in the codebase, but somewhat represents how we think squiggle ought to be tested.
|
The `invariants.pdf` document is _normative and aspirational_. It does not document tests as they exist in the codebase, but represents how we think squiggle ought to be tested.
|
||||||
|
|
||||||
|
We are partially bottlenecked by the rescript ecosystem's maturity with respect to property-based testing.
|
||||||
|
|
|
@ -3,31 +3,24 @@
|
||||||
}:
|
}:
|
||||||
# Style sheets https://github.com/citation-style-language/styles/
|
# Style sheets https://github.com/citation-style-language/styles/
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
|
||||||
let deps = [
|
let deps = [
|
||||||
# (texlive.combine
|
pandoc
|
||||||
# { inherit (texlive)
|
(texlive.combine
|
||||||
# scheme-small thmtools datetime xpatch fmtcount;
|
{ inherit (texlive) scheme-small datetime; }
|
||||||
# }
|
)
|
||||||
# )
|
]; in
|
||||||
haskellPackages.pandoc
|
stdenv.mkDerivation {
|
||||||
];
|
name = "render_squiggle_properties";
|
||||||
in
|
src = ./.;
|
||||||
stdenv.mkDerivation {
|
buildInputs = deps;
|
||||||
name = "render_squiggle_properties";
|
buildPhase = ''
|
||||||
src = ./.;
|
echo rendering...
|
||||||
buildInputs = deps;
|
pandoc -s invariants.md -o invariants.pdf
|
||||||
buildPhase = ''
|
echo rendered.
|
||||||
echo rendering...
|
'';
|
||||||
pandoc \
|
installPhase = ''
|
||||||
--from markdown \
|
mkdir -p $out
|
||||||
--to latex \
|
cp invariants.pdf $out/invariants.pdf
|
||||||
--out properties.pdf \
|
|
||||||
--pdf-engine xelatex \
|
|
||||||
properties.md \
|
|
||||||
echo rendered.
|
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
}
|
||||||
mkdir -p $out
|
|
||||||
cp properties.pdf $out/properties.pdf
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
BIN
packages/squiggle-lang/__tests__/docs/invariants-apr12.pdf
Normal file
BIN
packages/squiggle-lang/__tests__/docs/invariants-apr12.pdf
Normal file
Binary file not shown.
|
@ -1,38 +1,51 @@
|
||||||
# Property tests for squiggle
|
# Squiggle invariants
|
||||||
|
|
||||||
Here are some property tests for squiggle. I am testing mostly for the mean and the standard deviation. I know that squiggle doesn't yet have functions for the standard deviation, but they could be added.
|
Here are some property tests for squiggle. I am testing mostly for the mean and the standard deviation. I know that squiggle doesn't yet have functions for the standard deviation, but they could be added.
|
||||||
|
|
||||||
The keywords to search for are "[algebra of random variables](https://wikiless.org/wiki/Algebra_of_random_variables?lang=en)".
|
The keywords to search for are "[algebra of random variables](https://wikiless.org/wiki/Algebra_of_random_variables?lang=en)".
|
||||||
|
|
||||||
## Sums
|
## Means and standard deviations
|
||||||
|
### Sums
|
||||||
|
|
||||||
$$ mean(f+g) = mean(f) + mean(g) $$
|
$$ mean(f+g) = mean(f) + mean(g) $$
|
||||||
|
|
||||||
$$ Std(f+g) = sqrt(std(f)^2 + std(g)^2) $$
|
$$ std(f+g) = \sqrt{std(f)^2 + std(g)^2} $$
|
||||||
|
|
||||||
In the case of normal distributions,
|
In the case of normal distributions,
|
||||||
|
|
||||||
$$ normal(a,b) + normal(c,d) = normal(a+c, sqrt(b^2 + d^2) $$
|
$$ mean(normal(a,b) + normal(c,d)) = mean(normal(a+c, \sqrt{b^2 + d^2})) $$
|
||||||
|
|
||||||
## Substractions
|
### Subtractions
|
||||||
|
|
||||||
$$ mean(f-g) = mean(f) - mean(g) $$
|
$$ mean(f-g) = mean(f) - mean(g) $$
|
||||||
|
|
||||||
$$ std(f-g) = sqrt(std(f)^2 + std(g)^2) $$
|
$$ std(f-g) = \sqrt{std(f)^2 + std(g)^2} $$
|
||||||
|
|
||||||
## Multiplications
|
### Multiplications
|
||||||
|
|
||||||
$$ mean(f \cdot g) = mean(f) \cdot mean(g) $$
|
$$ mean(f \cdot g) = mean(f) \cdot mean(g) $$
|
||||||
|
|
||||||
$$ std(f \cdot g) = sqrt( (std(f)^2 + mean(f)) \cdot (std(g)^2 + mean(g)) - (mean(f) \cdot mean(y))^2) $$
|
$$ std(f \cdot g) = \sqrt{ (std(f)^2 + mean(f)) \cdot (std(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.
|
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.
|
||||||
|
|
||||||
## To do:
|
# To do:
|
||||||
|
|
||||||
- Provide sources or derivations, useful as this document becomes more complicated
|
- Provide sources or derivations, useful as this document becomes more complicated
|
||||||
- Provide definitions for the probability density function, exponential, inverse, log, etc.
|
- Provide definitions for the probability density function, exponential, inverse, log, etc.
|
||||||
- Provide at least some tests for division
|
- Provide at least some tests for division
|
||||||
- See if playing around with characteristic functions turns out anything useful
|
- See if playing around with characteristic functions turns out anything useful
|
||||||
|
|
||||||
|
## Probability density functions
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Cumulative density functions
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Inverse cumulative density functions
|
||||||
|
|
||||||
|
TODO
|
|
@ -1 +1 @@
|
||||||
pandoc -s property-tests.md -o property-tests.pdf
|
pandoc -s invariants.md -o invariants.pdf
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user