From 2b24bd979e282d35f3f8e15fd52ef3e5904af97e Mon Sep 17 00:00:00 2001 From: Iaroslav Date: Mon, 8 Jun 2020 17:36:14 +0700 Subject: [PATCH] Add Apache Javadocs references --- .../kmath/prob/samplers/AhrensDieterExponentialSampler.kt | 5 +++++ .../prob/samplers/BoxMullerNormalizedGaussianSampler.kt | 5 +++++ .../scientifik/kmath/prob/samplers/GaussianSampler.kt | 5 +++++ .../kmath/prob/samplers/KempSmallMeanPoissonSampler.kt | 5 +++++ .../kmath/prob/samplers/LargeMeanPoissonSampler.kt | 7 ++++++- .../prob/samplers/MarsagliaNormalizedGaussianSampler.kt | 5 +++++ .../scientifik/kmath/prob/samplers/PoissonSampler.kt | 6 +++++- .../kmath/prob/samplers/SmallMeanPoissonSampler.kt | 5 +++++ .../prob/samplers/ZigguratNormalizedGaussianSampler.kt | 5 +++++ 9 files changed, 46 insertions(+), 2 deletions(-) diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/AhrensDieterExponentialSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/AhrensDieterExponentialSampler.kt index 794c1010d..a83bf6e12 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/AhrensDieterExponentialSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/AhrensDieterExponentialSampler.kt @@ -7,6 +7,11 @@ import scientifik.kmath.prob.chain import kotlin.math.ln import kotlin.math.pow +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/AhrensDieterExponentialSampler.html + */ class AhrensDieterExponentialSampler private constructor(val mean: Double) : Sampler { override fun sample(generator: RandomGenerator): Chain = generator.chain { // Step 1: diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/BoxMullerNormalizedGaussianSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/BoxMullerNormalizedGaussianSampler.kt index 57c38d6b7..ef5b36289 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/BoxMullerNormalizedGaussianSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/BoxMullerNormalizedGaussianSampler.kt @@ -6,6 +6,11 @@ import scientifik.kmath.prob.Sampler import scientifik.kmath.prob.chain import kotlin.math.* +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/BoxMullerNormalizedGaussianSampler.html + */ class BoxMullerNormalizedGaussianSampler private constructor() : NormalizedGaussianSampler, Sampler { private var nextGaussian: Double = Double.NaN diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/GaussianSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/GaussianSampler.kt index 9af468858..2a6bd6a09 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/GaussianSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/GaussianSampler.kt @@ -5,6 +5,11 @@ import scientifik.kmath.chains.map import scientifik.kmath.prob.RandomGenerator import scientifik.kmath.prob.Sampler +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/GaussianSampler.html + */ class GaussianSampler private constructor( private val mean: Double, private val standardDeviation: Double, diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/KempSmallMeanPoissonSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/KempSmallMeanPoissonSampler.kt index 65e762b68..45afaa179 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/KempSmallMeanPoissonSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/KempSmallMeanPoissonSampler.kt @@ -6,6 +6,11 @@ import scientifik.kmath.prob.Sampler import scientifik.kmath.prob.chain import kotlin.math.exp +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/KempSmallMeanPoissonSampler.html + */ class KempSmallMeanPoissonSampler private constructor( private val p0: Double, private val mean: Double diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/LargeMeanPoissonSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/LargeMeanPoissonSampler.kt index 39a3dc168..f14aaa8ab 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/LargeMeanPoissonSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/LargeMeanPoissonSampler.kt @@ -8,9 +8,14 @@ import scientifik.kmath.prob.Sampler import scientifik.kmath.prob.next import kotlin.math.* +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/LargeMeanPoissonSampler.html + */ class LargeMeanPoissonSampler private constructor(val mean: Double) : Sampler { private val exponential: Sampler = AhrensDieterExponentialSampler.of(1.0) - private val gaussian: Sampler = ZigguratNormalizedGaussianSampler() + private val gaussian: Sampler = ZigguratNormalizedGaussianSampler.of() private val factorialLog: InternalUtils.FactorialLog = NO_CACHE_FACTORIAL_LOG private val lambda: Double = floor(mean) private val logLambda: Double = ln(lambda) diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/MarsagliaNormalizedGaussianSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/MarsagliaNormalizedGaussianSampler.kt index dd8f82a2c..a0711ec24 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/MarsagliaNormalizedGaussianSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/MarsagliaNormalizedGaussianSampler.kt @@ -7,6 +7,11 @@ import scientifik.kmath.prob.chain import kotlin.math.ln import kotlin.math.sqrt +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/MarsagliaNormalizedGaussianSampler.html + */ class MarsagliaNormalizedGaussianSampler private constructor(): NormalizedGaussianSampler, Sampler { private var nextGaussian = Double.NaN diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/PoissonSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/PoissonSampler.kt index 7b5dedc5b..3a85e6992 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/PoissonSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/PoissonSampler.kt @@ -4,7 +4,11 @@ import scientifik.kmath.chains.Chain import scientifik.kmath.prob.RandomGenerator import scientifik.kmath.prob.Sampler - +/** + * Based on commons-rng implementation. + * + * https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/PoissonSampler.html + */ class PoissonSampler private constructor( mean: Double ) : Sampler { diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/SmallMeanPoissonSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/SmallMeanPoissonSampler.kt index 7022b0f3a..966d7db9a 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/SmallMeanPoissonSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/SmallMeanPoissonSampler.kt @@ -8,6 +8,11 @@ import scientifik.kmath.prob.chain import kotlin.math.ceil import kotlin.math.exp +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/SmallMeanPoissonSampler.html + */ class SmallMeanPoissonSampler private constructor(mean: Double) : Sampler { private val p0: Double = exp(-mean) diff --git a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/ZigguratNormalizedGaussianSampler.kt b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/ZigguratNormalizedGaussianSampler.kt index 3d22c38a5..b1680d54a 100644 --- a/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/ZigguratNormalizedGaussianSampler.kt +++ b/kmath-prob/src/commonMain/kotlin/scientifik/kmath/prob/samplers/ZigguratNormalizedGaussianSampler.kt @@ -7,6 +7,11 @@ import scientifik.kmath.prob.Sampler import scientifik.kmath.prob.chain import kotlin.math.* +/** + * Based on commons-rng implementation. + * + * See https://commons.apache.org/proper/commons-rng/commons-rng-sampling/apidocs/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSampler.html + */ class ZigguratNormalizedGaussianSampler private constructor() : NormalizedGaussianSampler, Sampler {