Cleanup to documentation, changes to distribution colors

This commit is contained in:
Ozzie Gooen 2022-03-25 08:13:56 -04:00
parent bd53084bd8
commit 4a62681209
7 changed files with 43 additions and 38 deletions

View File

@ -84,7 +84,8 @@
"y": { "scale": "yscale", "field": "y" },
"y2": { "scale": "yscale", "value": 0 },
"fill": {
"signal": "{gradient: 'linear', x1: 1, y1: 1, x2: 0, y2: 1, stops: [ {offset: 0.0, color: 'steelblue'}, {offset: clamp(mousex, 0, 1), color: 'steelblue'}, {offset: clamp(mousex, 0, 1), color: 'blue'}, {offset: 1.0, color: 'blue'} ] }"
"signal": "{gradient: 'linear', x1: 1, y1: 1, x2: 0, y2: 1, stops: [ {offset: 0.0, color: '#11ac8f'}, {offset: clamp(mousex, 0, 1), color: '#11ac8f'}, {offset: clamp(mousex, 0, 1), color: '#1b6fac'}, {offset: 1.0, color: '#1b6fac'} ] }",
"color": "#000"
},
"interpolate": { "value": "monotone" },
"fillOpacity": { "value": 1 }

View File

@ -81,3 +81,9 @@ complicated, as it has to return either a number, or a distribution, or even
a representation of a function of distributions. Currently the export is simply
the generated type that rescript creates, and can be quite confusing. We therefore
highly recommend the use of typescript when creating tests or using this package.
## Potential Issues
If you experiment with generating different types of .gen.ts files and similar, note that they won't be caught by git (because they are in .gitignore). Make sure you delete these extra files, once they are unecessary.
```
rm src/rescript/**/*.gen.ts
```

View File

@ -9,7 +9,7 @@
"clean": "rescript clean",
"test": "jest",
"test:watch": "jest --watchAll",
"all": "yarn build && yarn bundle && yarn test"
"all": "yarn build && yarn bundle && yarn test",
},
"keywords": [
"Rescript"

View File

@ -1,7 +1,6 @@
module.exports = {
presets: [
require.resolve('@docusaurus/core/lib/babel/preset'),
["@babel/preset-react", {"runtime": "automatic"}]
require.resolve('@docusaurus/core/lib/babel/preset'),
["@babel/preset-react", { "runtime": "automatic" }]
],
};

View File

@ -13,14 +13,14 @@ import { SquiggleEditor } from '../src/components/SquiggleEditor'
The `normal(mean, sd)` function creates a normal distribution with the given mean
and standard deviation.
<SquiggleEditor initialSquiggleString="normal(0, 1)" />
<SquiggleEditor initialSquiggleString="normal(5, 1)" />
### Uniform distribution
The `uniform(low, high)` function creates a uniform distribution between the
two given numbers:
two given numbers.
<SquiggleEditor initialSquiggleString="uniform(0, 10)" />
<SquiggleEditor initialSquiggleString="uniform(3, 7)" />
### Lognormal distribution
@ -29,18 +29,18 @@ The `lognormal(mu, sigma)` returns the log of a normal distribution with paramet
mu and sigma. The log of lognormal(mu, sigma) is a normal distribution with parameters
mean mu and standard deviation sigma.
<SquiggleEditor initialSquiggleString="lognormal(0, 1)" />
<SquiggleEditor initialSquiggleString="lognormal(0, 0.7)" />
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 convinience as lognormal distributions are commonly used in practice.
<SquiggleEditor initialSquiggleString="2 to 10" />
Furthermore, it's also possible to create a lognormal from it's actual mean
and standard deviation, using `lognormalFromMeanAndStdDev`:
and standard deviation, using `lognormalFromMeanAndStdDev`.
<SquiggleEditor initialSquiggleString="lognormalFromMeanAndStdDev(20, 20)" />
<SquiggleEditor initialSquiggleString="lognormalFromMeanAndStdDev(20, 10)" />
### Beta distribution
@ -60,7 +60,7 @@ mean.
### The 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.
<SquiggleEditor initialSquiggleString="triangular(1, 2, 4)" />
@ -73,43 +73,42 @@ combination.
<SquiggleEditor initialSquiggleString="mm(uniform(0,1), normal(1,1), [0.5, 0.5])" />
It's possible to create discrete distributions using this method:
It's possible to create discrete distributions using this method.
<SquiggleEditor initialSquiggleString="mm(0, 1, [0.2,0.8])" />
As well as mixed distributions:
<SquiggleEditor initialSquiggleString="mm(0, 1 to 10, [0.2,0.8])" />
<SquiggleEditor initialSquiggleString="mm(3, 8, 1 to 10, [0.2, 0.3, 0.5])" />
## Other Functions
### PDF of a distribution
The `pdf(distribution, x)` function returns the density of a distribution at the
given point x:
given point x.
<SquiggleEditor initialSquiggleString="pdf(normal(0,1),0)" />
### Inverse of a distribution
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`
lower than x is equal to prob. It is the inverse of `cdf`.
<SquiggleEditor initialSquiggleString="inv(normal(0,1),0.5)" />
### CDF of a distribution
The `cdf(distribution,x)` gives the cumulative probability of the distribution
or all values lower than x. It is the inverse of `inv`:
or all values lower than x. It is the inverse of `inv`.
<SquiggleEditor initialSquiggleString="cdf(normal(0,1),0)" />
### Mean of a distribution
The `mean(distribution)` function gives the mean (expected value) of a distribution:
The `mean(distribution)` function gives the mean (expected value) of a distribution.
<SquiggleEditor initialSquiggleString="mean(normal(5, 10))" />
### Sampling a distribution
The `sample(distribution)` samples a given distribution:
The `sample(distribution)` samples a given distribution.
<SquiggleEditor initialSquiggleString="sample(normal(0, 10))" />

View File

@ -77,33 +77,33 @@ Right now, Monte Carlo simulations are totally random. It would be nicer to be a
- Possibly a decent web GUI (a much more advanced playground).
- A VS Code extention and similar.
## Fixes
## Bugs
- Discrete distributions are particularly buggy. Try ``mm(1,2,3,4,5,6,7,8,9,10) .* (5 to 8)``
## New Functions
### Distributions
```
cauchy() //todo
pareto() //todo
metalog() //todo
```js
cauchy()
pareto()
metalog()
```
Possibly change mm to mix, or mx(). Also, change input format, maybe to mx([a,b,c], [a,b,c]).
### Functions
```
samples(distribution, n) //todo
toPdf(distribution) //todo
toCdf(distribution) //todo
toHash(distribution) //todo. Make hash of content, like, {xs:[], ys:[]}
trunctate(distribution, leftValue, rightValue) //todo
leftTrunctate(distribution, leftValue) //todo
rightTrunctate(distribution, rightValue) //todo
distributionFromSamples(array, params) //todo
distributionFromPoints() //todo
distributionFromHash() //todo
```js
samples(distribution, n)
toPdf(distribution)
toCdf(distribution)
toHash(distribution)
trunctate(distribution, leftValue, rightValue)
leftTrunctate(distribution, leftValue)
rightTrunctate(distribution, rightValue)
distributionFromSamples(array, params)
distributionFromPoints()
distributionFromHash()
```

View File

@ -6,7 +6,7 @@ import { SquiggleEditor } from '../src/components/SquiggleEditor'
# Squiggle Language
The squiggle language has a very simply syntax. The best way to get to understand
The squiggle language has a very simple syntax. The best way to get to understand
it is by simply looking at examples.
## Basic Language