Documentation
API
PointSet

PointSet

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.

Constructors

make

Signatures
PointSet.make(Dist) => PointSetDist
PointSet.make(Number) => PointSetDist
Examples
PointSet.make(normal(5,10))
PointSet(3)

makeContinuous

Signatures
PointSet.makeContinuous(List({x: Number, y: Number})) => PointSetDist
Examples
PointSet.makeContinuous([
  {x: 0, y: 0.2},
  {x: 1, y: 0.7},
  {x: 2, y: 0.8},
  {x: 3, y: 0.2}
])

makeDiscrete

Signatures
PointSet.makeDiscrete(List({x: Number, y: Number})) => PointSetDist
Examples
PointSet.makeDiscrete([
  {x: 0, y: 0.2},
  {x: 1, y: 0.7},
  {x: 2, y: 0.8},
  {x: 3, y: 0.2}
])

Conversions

fromDist

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.

Signatures
PointSet.fromDist(Dist) => PointSetDist
Examples
PointSet.fromDist(normal(5,2))

fromNumber

Signatures
PointSet.fromNumber(Number) => PointSetDist
Examples
PointSet.fromNumber(3)

downsample

Signatures
PointSet.downsample(PointSetDist, newLength: Number) => PointSetDist
Examples
PointSet.downsample(PointSet.fromDist(normal(5,2)), 50)

support

Signatures
PointSet.support(PointSetDist) => {points: List(Number), segments: List([Number, Number])}
Examples
PointSet.support(PointSet.fromDist(normal(5,2)))

Transformations

mapY

Signatures
PointSet.mapY(PointSetDist, fn: (Number) => Number) => PointSetDist
Examples
PointSet.mapY(mx(Sym.normal(5,2)), {|x| x + 1})