Package dk.alexandra.fresco.stat
Class DefaultSampler
Object
DefaultSampler
- All Implemented Interfaces:
Sampler
public class DefaultSampler extends Object implements Sampler
-
Method Summary
Modifier and Type Method Description DRes<SInt>
sampleBernoulliDistribution(double p)
Draw a sample from a Bernoulli distribution with parameter p with 0 ≤ p ≤ 1.DRes<SInt>
sampleBernoulliDistribution(DRes<SFixed> p)
Draw a sample from a Bernoulli distribution with parameter p with 0 ≤ p ≤ 1.DRes<SInt>
sampleCategoricalDistribution(double[] probabilities)
Draw a sample from the set {0, ..., probabilities.length - 1} with probabilities[i] indicating the probability of drawing i.DRes<SInt>
sampleCategoricalDistribution(List<DRes<SFixed>> probabilities)
Draw a sample from the set {0, ..., probabilities.size() - 1} with probabilities.get(i) indicating the probability of drawing i.DRes<SInt>
sampleCategoricalDistribution(List<DRes<SFixed>> probabilities, boolean normalized)
Draw a sample from the set {0, ..., probabilities.size() - 1} with probabilities.get(i) indicating the probability of drawing i.DRes<SFixed>
sampleExponentialDistribution(double b)
Draw a sample from an exponential distribution with parameter λ = 1 / b with b gt; 0.DRes<SFixed>
sampleExponentialDistribution(DRes<SFixed> b)
Draw a sample from an exponential distribution with parameter λ = 1 / b with b gt; 0.DRes<SFixed>
sampleLaplaceDistribution(double b)
Draw a sample from a Laplace distribution with location 0 and scale b > 0.DRes<SFixed>
sampleLaplaceDistribution(DRes<SFixed> b)
Draw a sample from a Laplace distribution with location 0 and scale b gt; 0.DRes<SFixed>
sampleNormalDistribution()
Draw a sample from a normal distribution with mean 0 and variance 1.DRes<SInt>
sampleRademacherDistribution()
Draw a sample from a Rademacher distribution.DRes<SFixed>
sampleUniformDistribution()
Draw a sample form a uniform distribution on [0, 1).
-
Method Details
-
sampleBernoulliDistribution
public DRes<SInt> sampleBernoulliDistribution(DRes<SFixed> p)Description copied from interface:Sampler
Draw a sample from a Bernoulli distribution with parameter p with 0 ≤ p ≤ 1.- Specified by:
sampleBernoulliDistribution
in interfaceSampler
-
sampleBernoulliDistribution
public DRes<SInt> sampleBernoulliDistribution(double p)Description copied from interface:Sampler
Draw a sample from a Bernoulli distribution with parameter p with 0 ≤ p ≤ 1.- Specified by:
sampleBernoulliDistribution
in interfaceSampler
-
sampleCategoricalDistribution
Description copied from interface:Sampler
Draw a sample from the set {0, ..., probabilities.size() - 1} with probabilities.get(i) indicating the probability of drawing i. Note that the sum of probabilities should be equal to 1.- Specified by:
sampleCategoricalDistribution
in interfaceSampler
-
sampleCategoricalDistribution
public DRes<SInt> sampleCategoricalDistribution(List<DRes<SFixed>> probabilities, boolean normalized)Description copied from interface:Sampler
Draw a sample from the set {0, ..., probabilities.size() - 1} with probabilities.get(i) indicating the probability of drawing i. If it is not known whether the sum of the probabilities is equal to 1, the normalized parameter should be set tofalse
.- Specified by:
sampleCategoricalDistribution
in interfaceSampler
-
sampleCategoricalDistribution
public DRes<SInt> sampleCategoricalDistribution(double[] probabilities)Description copied from interface:Sampler
Draw a sample from the set {0, ..., probabilities.length - 1} with probabilities[i] indicating the probability of drawing i. Note that the sum of probabilities should be equal to 1.- Specified by:
sampleCategoricalDistribution
in interfaceSampler
-
sampleExponentialDistribution
public DRes<SFixed> sampleExponentialDistribution(DRes<SFixed> b)Description copied from interface:Sampler
Draw a sample from an exponential distribution with parameter λ = 1 / b with b gt; 0.- Specified by:
sampleExponentialDistribution
in interfaceSampler
-
sampleExponentialDistribution
public DRes<SFixed> sampleExponentialDistribution(double b)Description copied from interface:Sampler
Draw a sample from an exponential distribution with parameter λ = 1 / b with b gt; 0.- Specified by:
sampleExponentialDistribution
in interfaceSampler
-
sampleLaplaceDistribution
public DRes<SFixed> sampleLaplaceDistribution(double b)Description copied from interface:Sampler
Draw a sample from a Laplace distribution with location 0 and scale b > 0.- Specified by:
sampleLaplaceDistribution
in interfaceSampler
-
sampleLaplaceDistribution
public DRes<SFixed> sampleLaplaceDistribution(DRes<SFixed> b)Description copied from interface:Sampler
Draw a sample from a Laplace distribution with location 0 and scale b gt; 0.- Specified by:
sampleLaplaceDistribution
in interfaceSampler
-
sampleNormalDistribution
public DRes<SFixed> sampleNormalDistribution()Description copied from interface:Sampler
Draw a sample from a normal distribution with mean 0 and variance 1.- Specified by:
sampleNormalDistribution
in interfaceSampler
-
sampleRademacherDistribution
public DRes<SInt> sampleRademacherDistribution()Description copied from interface:Sampler
Draw a sample from a Rademacher distribution.- Specified by:
sampleRademacherDistribution
in interfaceSampler
-
sampleUniformDistribution
public DRes<SFixed> sampleUniformDistribution()Description copied from interface:Sampler
Draw a sample form a uniform distribution on [0, 1).- Specified by:
sampleUniformDistribution
in interfaceSampler
-