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

59 lines
1.7 KiB
Markdown
Raw Normal View History

2022-06-05 20:59:45 +00:00
---
2022-06-11 00:35:48 +00:00
sidebar_position: 4
2022-06-05 20:59:45 +00:00
title: Point Set Distribution
---
2022-06-14 23:47:31 +00:00
2022-06-14 23:12:29 +00:00
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.
2022-06-05 20:59:45 +00:00
2022-07-20 03:52:08 +00:00
### fromDist
2022-06-11 15:57:02 +00:00
2022-06-13 04:19:28 +00:00
Converts the distribution in question into a point set distribution. If the distribution is symbolic, then it does this by taking the quantiles. If the distribution is a sample set, then it uses a version of kernel density estimation to approximate the point set format. One complication of this latter process is that if there is a high proportion of overlapping samples (samples that are exactly the same as each other), it will convert these samples into discrete point masses. Eventually we'd like to add further methods to help adjust this process.
2022-06-06 05:16:29 +00:00
```
2022-07-20 03:52:08 +00:00
PointSet.fromDist: (distribution) => pointSetDist
2022-06-06 05:16:29 +00:00
```
2022-06-05 20:59:45 +00:00
2022-06-06 05:16:29 +00:00
### makeContinuous
2022-06-11 15:57:02 +00:00
2022-06-13 04:19:28 +00:00
Converts a set of x-y coordinates directly into a continuous distribution.
2022-06-06 05:16:29 +00:00
```
PointSet.makeContinuous: (list<{x: number, y: number}>) => pointSetDist
2022-06-05 20:59:45 +00:00
```
2022-06-13 04:19:28 +00:00
```javascript
PointSet.makeContinuous([
{ x: 0, y: 0.1 },
{ x: 1, y: 0.2 },
{ x: 2, y: 0.15 },
{ x: 3, y: 0.1 },
2022-06-13 19:10:24 +00:00
]);
2022-06-13 04:19:28 +00:00
```
2022-06-06 05:16:29 +00:00
### makeDiscrete
2022-06-13 19:10:24 +00:00
2022-06-06 05:16:29 +00:00
```
PointSet.makeDiscrete: (list<{x: number, y: number}>) => pointSetDist
2022-06-11 15:57:02 +00:00
```
2022-06-13 04:19:28 +00:00
```javascript
PointSet.makeDiscrete([
2022-06-13 04:19:28 +00:00
{ x: 0, y: 0.1 },
{ x: 1, y: 0.2 },
{ x: 2, y: 0.15 },
{ x: 3, y: 0.1 },
2022-06-13 19:10:24 +00:00
]);
2022-06-13 04:19:28 +00:00
```
### mapY
```
PointSet.mapY: (pointSetDist, (number => number)) => pointSetDist
```
```javascript
normal(5,3) |> PointSet.fromDist |> PointSet.mapY({|x| x ^ 2}) |> normalize
2022-08-20 22:59:25 +00:00
```