squiggle/packages/website/docs/Api/DistSampleSet.md

67 lines
1.4 KiB
Markdown
Raw Normal View History

2022-06-06 04:47:29 +00:00
---
2022-06-11 00:35:48 +00:00
sidebar_position: 5
2022-06-06 04:47:29 +00:00
title: Sample Set Distribution
---
2022-06-14 23:47:31 +00:00
2022-06-14 23:12:29 +00:00
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.
2022-06-14 23:47:31 +00:00
Monte Carlo calculations typically result in sample set distributions.
2022-06-14 23:12:29 +00:00
All regular distribution function work on sample set distributions. In addition, there are several functions that only work on sample set distributions.
2022-06-06 04:47:29 +00:00
2022-07-20 03:52:08 +00:00
### fromDist
2022-07-21 18:41:32 +00:00
2022-07-20 03:52:08 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.fromDist: (list<number>) => sampleSet
2022-07-20 03:52:08 +00:00
```
2022-06-11 15:57:02 +00:00
2022-07-20 03:52:08 +00:00
### fromList
2022-07-21 18:41:32 +00:00
2022-06-06 04:47:29 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.fromList: (list<number>) => sampleSet
2022-06-06 04:47:29 +00:00
```
2022-07-21 18:41:32 +00:00
### fromFn
2022-06-11 15:57:02 +00:00
2022-06-06 04:47:29 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.fromFn: ((float) => number) => sampleSet
2022-06-06 04:47:29 +00:00
```
2022-07-20 03:52:08 +00:00
### toList
2022-06-11 15:57:02 +00:00
2022-06-06 04:47:29 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.toList: (sampleSet) => list<number>
2022-06-06 04:47:29 +00:00
```
2022-07-20 03:52:08 +00:00
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**
2022-06-11 15:57:02 +00:00
2022-06-06 04:47:29 +00:00
```
toList(SampleSet.fromDist(normal(5,2)))
2022-06-06 04:47:29 +00:00
```
2022-07-20 03:52:08 +00:00
### map
2022-06-11 15:57:02 +00:00
2022-06-06 04:47:29 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.map: (sampleSet, (number => number)) => sampleSet
2022-06-06 04:47:29 +00:00
```
2022-07-20 03:52:08 +00:00
### map2
2022-06-06 04:47:29 +00:00
2022-07-20 03:52:08 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.map2: (sampleSet, sampleSet, ((number, number) => number)) => sampleSet
2022-07-20 03:52:08 +00:00
```
### map3
2022-06-11 15:57:02 +00:00
2022-06-06 04:47:29 +00:00
```
2022-07-21 21:59:36 +00:00
SampleSet.map3: (sampleSet, sampleSet, sampleSet, ((number, number, number) => number)) => sampleSet
2022-06-11 15:57:02 +00:00
```
2022-07-21 18:29:59 +00:00
### mapN
```
2022-07-21 22:36:56 +00:00
SampleSet.mapN: (list<sampleSet>, (list<sampleSet> => number)) => sampleSet
2022-07-21 18:41:32 +00:00
```