Added descriptions to last API types

This commit is contained in:
Ozzie Gooen 2022-06-14 16:12:29 -07:00
parent d4e3579211
commit 1d4aea2731
5 changed files with 35 additions and 5 deletions

View File

@ -292,7 +292,7 @@ quantile(normal(5, 2), 0.5);
**TODO: Will soon be called "PointSet.make"** **TODO: Will soon be called "PointSet.make"**
Converts a distribution to the pointSet format Converts a distribution to the pointSet format.
``` ```
toPointSet: (distribution) => pointSetDistribution toPointSet: (distribution) => pointSetDistribution
@ -308,7 +308,7 @@ toPointSet(normal(5, 2));
**TODO: Will soon be called "SampleSet.make"** **TODO: Will soon be called "SampleSet.make"**
Converts a distribution to the sampleSet format, with n samples Converts a distribution to the sampleSet format, with n samples.
``` ```
toSampleSet: (distribution, number) => sampleSetDistribution toSampleSet: (distribution, number) => sampleSetDistribution

View File

@ -2,6 +2,13 @@
sidebar_position: 4 sidebar_position: 4
title: Point Set Distribution title: Point Set Distribution
--- ---
:::danger
These functions aren't yet implemented with these specific names. This should be changed soon
:::
Point set distributions are one of the three distribution formats. They are stored as a list of x-y coordinates representing both discrete and continuous distributions.
One complication is that it's possible to represent invalid probability distributions in the point set format. For example, you can represent shapes with negative values, or shapes that are not normalized.
### make ### make

View File

@ -2,13 +2,22 @@
sidebar_position: 5 sidebar_position: 5
title: Sample Set Distribution title: Sample Set Distribution
--- ---
:::danger
These functions aren't yet implemented with these specific names. This should be added soon.
:::
Sample set distributions are one of the three distribution formats. Internally, they are stored as a list of numbers. It's useful to distinguish point set distributions from arbitrary lists of numbers to make it clear which functions are applicable.
Monte Carlo calculations typically result in sample set distributions.
All regular distribution function work on sample set distributions. In addition, there are several functions that only work on sample set distributions.
### make ### make
``` ```
SampleSet.make: (distribution) => sampleSet SampleSet.make: (distribution) => sampleSet
SampleSet.make: (() => number) => sampleSet
SampleSet.make: (list<number>) => sampleSet SampleSet.make: (list<number>) => sampleSet
SampleSet.make: (() => number) => sampleSet // not yet implemented
``` ```
### map ### map
@ -35,7 +44,7 @@ SampleSet.map3: (sampleSet, sampleSet, sampleSet, ((number, number, number) => n
SampleSet.toList: (sampleSet) => list<number> SampleSet.toList: (sampleSet) => list<number>
``` ```
Gets the internal samples of a sampleSet distribution. This is separate from the sampleN() function, which would shuffle the samples. toList() maintains order and length. Gets the internal samples of a sampleSet distribution. This is separate from the sampleN() function, which would shuffle the samples. toList() maintains order and length. Gets the internal samples of a sampleSet distribution. This is separate from the sampleN() function, which would shuffle the samples. toList() maintains order and length.
**Examples** **Examples**

View File

@ -3,13 +3,21 @@ sidebar_position: 7
title: List title: List
--- ---
Squiggle lists are a lot like Python lists or Ruby arrays. They accept all types.
```javascript
myList = [3, normal(5,2), "random"]
```
### make ### make
**Note: currently just called ``makeList``, without the preix**
``` ```
List.make: (number, 'a) => list<'a> List.make: (number, 'a) => list<'a>
``` ```
Returns an array of size `n` filled with value `e`. Returns an array of size `n` filled with the value.
```js ```js
List.make(4, 1); // creates the list [1, 1, 1, 1] List.make(4, 1); // creates the list [1, 1, 1, 1]
@ -31,6 +39,8 @@ length: (list<'a>) => number
### up to ### up to
**Note: currently just called ``upTo``, without the preix**
``` ```
List.upTo: (low:number, high:number) => list<number> List.upTo: (low:number, high:number) => list<number>
``` ```

View File

@ -3,6 +3,10 @@ sidebar_position: 9
title: Number title: Number
--- ---
Squiggle ``numbers`` are Javascript floats.
Many of the functions below work on lists or pairs of numbers.
import TOCInline from "@theme/TOCInline"; import TOCInline from "@theme/TOCInline";
<TOCInline toc={toc} /> <TOCInline toc={toc} />