From f18cd9ad40e2e3b9ef0365c743d059267eab0b3a Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Sun, 29 Nov 2020 16:25:08 +0700 Subject: [PATCH] Fix package names --- .../kmath/commons/prob/DistributionBenchmark.kt | 8 ++++---- .../kmath/commons/prob/DistributionDemo.kt | 4 ++-- .../kmath/commons/optimization/OptimizeTest.kt | 15 +++++---------- .../stat/distributions/NormalDistribution.kt | 14 +++++++------- .../kscience/kmath/stat/internal/InternalErf.kt | 2 +- .../kscience/kmath/stat/internal/InternalGamma.kt | 2 +- .../kscience/kmath/stat/internal/InternalUtils.kt | 2 +- .../samplers/AhrensDieterExponentialSampler.kt | 10 +++++----- .../AhrensDieterMarsagliaTsangGammaSampler.kt | 10 +++++----- .../stat/samplers/AliasMethodDiscreteSampler.kt | 10 +++++----- .../BoxMullerNormalizedGaussianSampler.kt | 8 ++++---- .../kmath/stat/samplers/GaussianSampler.kt | 6 +++--- .../stat/samplers/KempSmallMeanPoissonSampler.kt | 8 ++++---- .../stat/samplers/LargeMeanPoissonSampler.kt | 12 ++++++------ .../MarsagliaNormalizedGaussianSampler.kt | 8 ++++---- .../stat/samplers/NormalizedGaussianSampler.kt | 4 ++-- .../kmath/stat/samplers/PoissonSampler.kt | 6 +++--- .../stat/samplers/SmallMeanPoissonSampler.kt | 8 ++++---- .../samplers/ZigguratNormalizedGaussianSampler.kt | 8 ++++---- .../kmath/stat/CommonsDistributionsTest.kt | 2 +- 20 files changed, 71 insertions(+), 76 deletions(-) diff --git a/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionBenchmark.kt b/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionBenchmark.kt index e4a5bc534..5c7442c1b 100644 --- a/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionBenchmark.kt +++ b/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionBenchmark.kt @@ -3,10 +3,10 @@ package kscience.kmath.commons.prob import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.blocking -import kscience.kmath.prob.fromSource -import kscience.kmath.prob.samplers.GaussianSampler +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.blocking +import kscience.kmath.stat.fromSource +import kscience.kmath.stat.samplers.GaussianSampler import org.apache.commons.rng.simple.RandomSource import java.time.Duration import java.time.Instant diff --git a/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionDemo.kt b/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionDemo.kt index 7f06f4a1f..c96826ef7 100644 --- a/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionDemo.kt +++ b/examples/src/main/kotlin/kscience/kmath/commons/prob/DistributionDemo.kt @@ -3,8 +3,8 @@ package kscience.kmath.commons.prob import kotlinx.coroutines.runBlocking import kscience.kmath.chains.Chain import kscience.kmath.chains.collectWithState -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.samplers.ZigguratNormalizedGaussianSampler +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.samplers.ZigguratNormalizedGaussianSampler private data class AveragingChainState(var num: Int = 0, var value: Double = 0.0) diff --git a/kmath-commons/src/test/kotlin/kscience/kmath/commons/optimization/OptimizeTest.kt b/kmath-commons/src/test/kotlin/kscience/kmath/commons/optimization/OptimizeTest.kt index 3290c8f32..184d209d5 100644 --- a/kmath-commons/src/test/kotlin/kscience/kmath/commons/optimization/OptimizeTest.kt +++ b/kmath-commons/src/test/kotlin/kscience/kmath/commons/optimization/OptimizeTest.kt @@ -1,11 +1,11 @@ package kscience.kmath.commons.optimization +import kotlinx.coroutines.runBlocking import kscience.kmath.commons.expressions.DerivativeStructureExpression import kscience.kmath.expressions.symbol -import kscience.kmath.stat.Distribution import kscience.kmath.stat.Fitting import kscience.kmath.stat.RandomGenerator -import kscience.kmath.stat.normal +import kscience.kmath.stat.distributions.NormalDistribution import org.junit.jupiter.api.Test import kotlin.math.pow @@ -39,20 +39,15 @@ internal class OptimizeTest { } @Test - fun testCmFit() { + fun testCmFit() = runBlocking { val a by symbol val b by symbol val c by symbol - val sigma = 1.0 - val generator = Distribution.normal(0.0, sigma) + val generator = NormalDistribution(0.0, sigma) val chain = generator.sample(RandomGenerator.default(112667)) val x = (1..100).map(Int::toDouble) - - val y = x.map { - it.pow(2) + it + 1 + chain.nextDouble() - } - + val y = x.map { it.pow(2) + it + 1.0 + chain.next() } val yErr = List(x.size) { sigma } val chi2 = Fitting.chiSquared(x, y, yErr) { x1 -> diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/distributions/NormalDistribution.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/distributions/NormalDistribution.kt index 57c39018d..4332d92fe 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/distributions/NormalDistribution.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/distributions/NormalDistribution.kt @@ -1,12 +1,12 @@ -package kscience.kmath.prob.distributions +package kscience.kmath.stat.distributions import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.UnivariateDistribution -import kscience.kmath.prob.internal.InternalErf -import kscience.kmath.prob.samplers.GaussianSampler -import kscience.kmath.prob.samplers.NormalizedGaussianSampler -import kscience.kmath.prob.samplers.ZigguratNormalizedGaussianSampler +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.UnivariateDistribution +import kscience.kmath.stat.internal.InternalErf +import kscience.kmath.stat.samplers.GaussianSampler +import kscience.kmath.stat.samplers.NormalizedGaussianSampler +import kscience.kmath.stat.samplers.ZigguratNormalizedGaussianSampler import kotlin.math.* public inline class NormalDistribution(public val sampler: GaussianSampler) : UnivariateDistribution { diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalErf.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalErf.kt index 178423e68..bcc4d1481 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalErf.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalErf.kt @@ -1,4 +1,4 @@ -package kscience.kmath.prob.internal +package kscience.kmath.stat.internal import kotlin.math.abs diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalGamma.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalGamma.kt index 8a73659db..dce84712a 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalGamma.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalGamma.kt @@ -1,4 +1,4 @@ -package kscience.kmath.prob.internal +package kscience.kmath.stat.internal import kotlin.math.* diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalUtils.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalUtils.kt index 837c9796c..9997eeb57 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalUtils.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/internal/InternalUtils.kt @@ -1,4 +1,4 @@ -package kscience.kmath.prob.internal +package kscience.kmath.stat.internal import kotlin.math.ln import kotlin.math.min diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterExponentialSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterExponentialSampler.kt index d4b443e9c..cea6de20d 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterExponentialSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterExponentialSampler.kt @@ -1,10 +1,10 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain -import kscience.kmath.prob.internal.InternalUtils +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain +import kscience.kmath.stat.internal.InternalUtils import kotlin.math.ln import kotlin.math.pow diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterMarsagliaTsangGammaSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterMarsagliaTsangGammaSampler.kt index e18a44cb9..f36e34f34 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterMarsagliaTsangGammaSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AhrensDieterMarsagliaTsangGammaSampler.kt @@ -1,10 +1,10 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain -import kscience.kmath.prob.next +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain +import kscience.kmath.stat.next import kotlin.math.* /** diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AliasMethodDiscreteSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AliasMethodDiscreteSampler.kt index db78a41a8..a76fcd543 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AliasMethodDiscreteSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/AliasMethodDiscreteSampler.kt @@ -1,10 +1,10 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain -import kscience.kmath.prob.internal.InternalUtils +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain +import kscience.kmath.stat.internal.InternalUtils import kotlin.math.ceil import kotlin.math.max import kotlin.math.min diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/BoxMullerNormalizedGaussianSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/BoxMullerNormalizedGaussianSampler.kt index 50a7b00c2..dc3a9b3e6 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/BoxMullerNormalizedGaussianSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/BoxMullerNormalizedGaussianSampler.kt @@ -1,9 +1,9 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain import kotlin.math.* /** diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/GaussianSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/GaussianSampler.kt index 1a5e4cfdd..5e54d2f18 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/GaussianSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/GaussianSampler.kt @@ -1,9 +1,9 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain import kscience.kmath.chains.map -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler /** * Sampling from a Gaussian distribution with given mean and standard deviation. diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/KempSmallMeanPoissonSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/KempSmallMeanPoissonSampler.kt index 624fc9a7e..4b04f3e6f 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/KempSmallMeanPoissonSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/KempSmallMeanPoissonSampler.kt @@ -1,9 +1,9 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain import kotlin.math.exp /** diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/LargeMeanPoissonSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/LargeMeanPoissonSampler.kt index 8a54fabaa..a841d47fc 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/LargeMeanPoissonSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/LargeMeanPoissonSampler.kt @@ -1,12 +1,12 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain import kscience.kmath.chains.ConstantChain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain -import kscience.kmath.prob.internal.InternalUtils -import kscience.kmath.prob.next +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain +import kscience.kmath.stat.internal.InternalUtils +import kscience.kmath.stat.next import kotlin.math.* /** diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/MarsagliaNormalizedGaussianSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/MarsagliaNormalizedGaussianSampler.kt index 69c04c20b..1696a7701 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/MarsagliaNormalizedGaussianSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/MarsagliaNormalizedGaussianSampler.kt @@ -1,9 +1,9 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain import kotlin.math.ln import kotlin.math.sqrt diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/NormalizedGaussianSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/NormalizedGaussianSampler.kt index af2ab876d..8995d3030 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/NormalizedGaussianSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/NormalizedGaussianSampler.kt @@ -1,6 +1,6 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers -import kscience.kmath.prob.Sampler +import kscience.kmath.stat.Sampler /** * Marker interface for a sampler that generates values from an N(0,1) diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/PoissonSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/PoissonSampler.kt index 02d8d5632..415e9c826 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/PoissonSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/PoissonSampler.kt @@ -1,8 +1,8 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler /** * Sampler for the Poisson distribution. diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/SmallMeanPoissonSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/SmallMeanPoissonSampler.kt index ff4233288..61d7e3484 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/SmallMeanPoissonSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/SmallMeanPoissonSampler.kt @@ -1,9 +1,9 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain import kotlin.math.ceil import kotlin.math.exp diff --git a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/ZigguratNormalizedGaussianSampler.kt b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/ZigguratNormalizedGaussianSampler.kt index 60407e604..c0c9c28e0 100644 --- a/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/ZigguratNormalizedGaussianSampler.kt +++ b/kmath-stat/src/commonMain/kotlin/kscience/kmath/stat/samplers/ZigguratNormalizedGaussianSampler.kt @@ -1,9 +1,9 @@ -package kscience.kmath.prob.samplers +package kscience.kmath.stat.samplers import kscience.kmath.chains.Chain -import kscience.kmath.prob.RandomGenerator -import kscience.kmath.prob.Sampler -import kscience.kmath.prob.chain +import kscience.kmath.stat.RandomGenerator +import kscience.kmath.stat.Sampler +import kscience.kmath.stat.chain import kotlin.math.* /** diff --git a/kmath-stat/src/jvmTest/kotlin/kscience/kmath/stat/CommonsDistributionsTest.kt b/kmath-stat/src/jvmTest/kotlin/kscience/kmath/stat/CommonsDistributionsTest.kt index 63cb33f7b..8090f9b2b 100644 --- a/kmath-stat/src/jvmTest/kotlin/kscience/kmath/stat/CommonsDistributionsTest.kt +++ b/kmath-stat/src/jvmTest/kotlin/kscience/kmath/stat/CommonsDistributionsTest.kt @@ -3,7 +3,7 @@ package kscience.kmath.stat import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking -import kscience.kmath.prob.samplers.GaussianSampler +import kscience.kmath.stat.samplers.GaussianSampler import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test