# SampleSet

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.

## Constructors

### make

Calls the correct conversion constructor, based on the corresponding input type, to create a sample set distribution

SampleSet(5)

SampleSet.make([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])

SampleSet.make({|i| sample(normal(5,2))})

## Conversions

### fromDist

Converts any distribution type into a sample set distribution.

SampleSet.fromDist(Sym.normal(5,2))

### fromNumber

Convert a number into a sample set distribution that contains `n`

copies of that number. `n`

refers to the model sample count.

SampleSet.fromNumber(3)

### fromList

Convert a list of numbers into a sample set distribution.

SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5,3,2,3,1,1,3])

### toList

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.

SampleSet.toList(SampleSet.fromDist(normal(5,2)))

### fromFn

Convert a function into a sample set distribution by calling it `n`

times.

SampleSet.fromFn({|i| sample(normal(5,2))})

## Transformations

### map

Transforms a sample set distribution by applying a function to each sample. Returns a new sample set distribution.

SampleSet.map(SampleSet.fromDist(normal(5,2)), {|x| x + 1})

### map2

Transforms two sample set distributions by applying a function to each pair of samples. Returns a new sample set distribution.

SampleSet.map2( SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y| x + y} )

### map3

SampleSet.map3( SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), {|x, y, z| max([x,y,z])} )

### mapN

SampleSet.mapN( [ SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)), SampleSet.fromDist(normal(5,2)) ], max )