Skip to content
Permalink
Browse files
Add TSampler to example sampling application
  • Loading branch information
aherbert committed Mar 2, 2022
1 parent 88608c2 commit af2e5892c6169b541c7125e8d5707af93ea1b276
Showing 2 changed files with 14 additions and 1 deletion.
@@ -32,6 +32,7 @@
import org.apache.commons.rng.sampling.distribution.ZigguratSampler;
import org.apache.commons.rng.sampling.distribution.MarsagliaNormalizedGaussianSampler;
import org.apache.commons.rng.sampling.distribution.StableSampler;
import org.apache.commons.rng.sampling.distribution.TSampler;
import org.apache.commons.rng.sampling.distribution.BoxMullerNormalizedGaussianSampler;
import org.apache.commons.rng.sampling.distribution.ChengBetaSampler;
import org.apache.commons.rng.sampling.distribution.AhrensDieterExponentialSampler;
@@ -48,7 +49,7 @@
*/
@Command(name = "density",
description = {"Approximate the probability density of samplers."})
class ProbabilityDensityApproximationCommand implements Callable<Void> {
class ProbabilityDensityApproximationCommand implements Callable<Void> {
/** The standard options. */
@Mixin
private StandardOptions reusableOptions;
@@ -120,6 +121,8 @@ enum Sampler {
LevySampler,
/** The stable sampler. */
StableSampler,
/** The t sampler. */
TSampler,
}

/**
@@ -327,6 +330,15 @@ public Void call() throws IOException {
stableMin, stableMax, "stable");
}

if (samplers.contains(Sampler.TSampler)) {
final double tDegreesOfFreedom = 1.23;
// Quantiles 0.02 to 0.98 (avoid long tail to infinity)
final double tMin = -9.9264;
final double tMax = 9.9264;
createDensity(TSampler.of(rng, tDegreesOfFreedom),
tMin, tMax, "t");
}

return null;
}
}
@@ -32,6 +32,7 @@
<suppress checks="LineLength" files=".*[/\\]test[/\\].*" />
<suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" />
<suppress checks="MethodLength" files="(MersenneTwister64|Well44497[ab]|MultiplyWithCarry256)Test" />
<suppress checks="MethodLength" files="ProbabilityDensityApproximationCommand" />
<suppress checks="FileLength" files="[\\/]StableSamplerTest" />
<suppress checks="FileLength" files="[\\/]ZigguratSamplerPerformance" />
</suppressions>

0 comments on commit af2e589

Please sign in to comment.