Cleanup to documentation, changes to distribution colors
This commit is contained in:
parent
bd53084bd8
commit
4a62681209
|
@ -84,7 +84,8 @@
|
||||||
"y": { "scale": "yscale", "field": "y" },
|
"y": { "scale": "yscale", "field": "y" },
|
||||||
"y2": { "scale": "yscale", "value": 0 },
|
"y2": { "scale": "yscale", "value": 0 },
|
||||||
"fill": {
|
"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" },
|
"interpolate": { "value": "monotone" },
|
||||||
"fillOpacity": { "value": 1 }
|
"fillOpacity": { "value": 1 }
|
||||||
|
|
|
@ -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
|
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
|
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.
|
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
|
||||||
|
```
|
|
@ -9,7 +9,7 @@
|
||||||
"clean": "rescript clean",
|
"clean": "rescript clean",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watchAll",
|
"test:watch": "jest --watchAll",
|
||||||
"all": "yarn build && yarn bundle && yarn test"
|
"all": "yarn build && yarn bundle && yarn test",
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Rescript"
|
"Rescript"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
presets: [
|
presets: [
|
||||||
require.resolve('@docusaurus/core/lib/babel/preset'),
|
require.resolve('@docusaurus/core/lib/babel/preset'),
|
||||||
["@babel/preset-react", {"runtime": "automatic"}]
|
["@babel/preset-react", { "runtime": "automatic" }]
|
||||||
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,14 +13,14 @@ import { SquiggleEditor } from '../src/components/SquiggleEditor'
|
||||||
The `normal(mean, sd)` function creates a normal distribution with the given mean
|
The `normal(mean, sd)` function creates a normal distribution with the given mean
|
||||||
and standard deviation.
|
and standard deviation.
|
||||||
|
|
||||||
<SquiggleEditor initialSquiggleString="normal(0, 1)" />
|
<SquiggleEditor initialSquiggleString="normal(5, 1)" />
|
||||||
|
|
||||||
### Uniform distribution
|
### Uniform distribution
|
||||||
|
|
||||||
The `uniform(low, high)` function creates a uniform distribution between the
|
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
|
### 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
|
mu and sigma. The log of lognormal(mu, sigma) is a normal distribution with parameters
|
||||||
mean mu and standard deviation sigma.
|
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
|
An alternative format is also available. The "to" notation creates a lognormal
|
||||||
distribution with a 90% confidence interval between the two numbers. We add
|
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" />
|
<SquiggleEditor initialSquiggleString="2 to 10" />
|
||||||
|
|
||||||
Furthermore, it's also possible to create a lognormal from it's actual mean
|
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
|
### Beta distribution
|
||||||
|
@ -60,7 +60,7 @@ mean.
|
||||||
### The Triangular distribution
|
### The Triangular distribution
|
||||||
|
|
||||||
The `triangular(a,b,c)` function creates a triangular distribution with lower
|
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)" />
|
<SquiggleEditor initialSquiggleString="triangular(1, 2, 4)" />
|
||||||
|
|
||||||
|
@ -73,43 +73,42 @@ combination.
|
||||||
|
|
||||||
<SquiggleEditor initialSquiggleString="mm(uniform(0,1), normal(1,1), [0.5, 0.5])" />
|
<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])" />
|
<SquiggleEditor initialSquiggleString="mm(0, 1, [0.2,0.8])" />
|
||||||
|
|
||||||
As well as mixed distributions:
|
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
|
## Other Functions
|
||||||
|
|
||||||
### PDF of a distribution
|
### PDF of a distribution
|
||||||
The `pdf(distribution, x)` function returns the density of a distribution at the
|
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)" />
|
<SquiggleEditor initialSquiggleString="pdf(normal(0,1),0)" />
|
||||||
|
|
||||||
### Inverse of a distribution
|
### Inverse of a distribution
|
||||||
|
|
||||||
The `inv(distribution, prob)` gives the value x or which the probability for all values
|
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)" />
|
<SquiggleEditor initialSquiggleString="inv(normal(0,1),0.5)" />
|
||||||
|
|
||||||
### CDF of a distribution
|
### CDF of a distribution
|
||||||
|
|
||||||
The `cdf(distribution,x)` gives the cumulative probability of the 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)" />
|
<SquiggleEditor initialSquiggleString="cdf(normal(0,1),0)" />
|
||||||
|
|
||||||
### Mean of a distribution
|
### 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))" />
|
<SquiggleEditor initialSquiggleString="mean(normal(5, 10))" />
|
||||||
|
|
||||||
### Sampling a distribution
|
### Sampling a distribution
|
||||||
The `sample(distribution)` samples a given distribution:
|
The `sample(distribution)` samples a given distribution.
|
||||||
|
|
||||||
<SquiggleEditor initialSquiggleString="sample(normal(0, 10))" />
|
<SquiggleEditor initialSquiggleString="sample(normal(0, 10))" />
|
||||||
|
|
|
@ -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).
|
- Possibly a decent web GUI (a much more advanced playground).
|
||||||
- A VS Code extention and similar.
|
- 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)``
|
- Discrete distributions are particularly buggy. Try ``mm(1,2,3,4,5,6,7,8,9,10) .* (5 to 8)``
|
||||||
|
|
||||||
## New Functions
|
## New Functions
|
||||||
|
|
||||||
### Distributions
|
### Distributions
|
||||||
```
|
```js
|
||||||
cauchy() //todo
|
cauchy()
|
||||||
pareto() //todo
|
pareto()
|
||||||
metalog() //todo
|
metalog()
|
||||||
```
|
```
|
||||||
|
|
||||||
Possibly change mm to mix, or mx(). Also, change input format, maybe to mx([a,b,c], [a,b,c]).
|
Possibly change mm to mix, or mx(). Also, change input format, maybe to mx([a,b,c], [a,b,c]).
|
||||||
|
|
||||||
|
|
||||||
### Functions
|
### Functions
|
||||||
```
|
```js
|
||||||
samples(distribution, n) //todo
|
samples(distribution, n)
|
||||||
toPdf(distribution) //todo
|
toPdf(distribution)
|
||||||
toCdf(distribution) //todo
|
toCdf(distribution)
|
||||||
toHash(distribution) //todo. Make hash of content, like, {xs:[], ys:[]}
|
toHash(distribution)
|
||||||
trunctate(distribution, leftValue, rightValue) //todo
|
trunctate(distribution, leftValue, rightValue)
|
||||||
leftTrunctate(distribution, leftValue) //todo
|
leftTrunctate(distribution, leftValue)
|
||||||
rightTrunctate(distribution, rightValue) //todo
|
rightTrunctate(distribution, rightValue)
|
||||||
distributionFromSamples(array, params) //todo
|
distributionFromSamples(array, params)
|
||||||
distributionFromPoints() //todo
|
distributionFromPoints()
|
||||||
distributionFromHash() //todo
|
distributionFromHash()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { SquiggleEditor } from '../src/components/SquiggleEditor'
|
||||||
|
|
||||||
# Squiggle Language
|
# 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.
|
it is by simply looking at examples.
|
||||||
|
|
||||||
## Basic Language
|
## Basic Language
|
||||||
|
|
Loading…
Reference in New Issue
Block a user