forked from kscience/kmath
Fix package names
This commit is contained in:
parent
3c602e859d
commit
f18cd9ad40
@ -3,10 +3,10 @@ package kscience.kmath.commons.prob
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.blocking
|
import kscience.kmath.stat.blocking
|
||||||
import kscience.kmath.prob.fromSource
|
import kscience.kmath.stat.fromSource
|
||||||
import kscience.kmath.prob.samplers.GaussianSampler
|
import kscience.kmath.stat.samplers.GaussianSampler
|
||||||
import org.apache.commons.rng.simple.RandomSource
|
import org.apache.commons.rng.simple.RandomSource
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
@ -3,8 +3,8 @@ package kscience.kmath.commons.prob
|
|||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.chains.collectWithState
|
import kscience.kmath.chains.collectWithState
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.samplers.ZigguratNormalizedGaussianSampler
|
import kscience.kmath.stat.samplers.ZigguratNormalizedGaussianSampler
|
||||||
|
|
||||||
private data class AveragingChainState(var num: Int = 0, var value: Double = 0.0)
|
private data class AveragingChainState(var num: Int = 0, var value: Double = 0.0)
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package kscience.kmath.commons.optimization
|
package kscience.kmath.commons.optimization
|
||||||
|
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kscience.kmath.commons.expressions.DerivativeStructureExpression
|
import kscience.kmath.commons.expressions.DerivativeStructureExpression
|
||||||
import kscience.kmath.expressions.symbol
|
import kscience.kmath.expressions.symbol
|
||||||
import kscience.kmath.stat.Distribution
|
|
||||||
import kscience.kmath.stat.Fitting
|
import kscience.kmath.stat.Fitting
|
||||||
import kscience.kmath.stat.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.stat.normal
|
import kscience.kmath.stat.distributions.NormalDistribution
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
@ -39,20 +39,15 @@ internal class OptimizeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCmFit() {
|
fun testCmFit() = runBlocking {
|
||||||
val a by symbol
|
val a by symbol
|
||||||
val b by symbol
|
val b by symbol
|
||||||
val c by symbol
|
val c by symbol
|
||||||
|
|
||||||
val sigma = 1.0
|
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 chain = generator.sample(RandomGenerator.default(112667))
|
||||||
val x = (1..100).map(Int::toDouble)
|
val x = (1..100).map(Int::toDouble)
|
||||||
|
val y = x.map { it.pow(2) + it + 1.0 + chain.next() }
|
||||||
val y = x.map {
|
|
||||||
it.pow(2) + it + 1 + chain.nextDouble()
|
|
||||||
}
|
|
||||||
|
|
||||||
val yErr = List(x.size) { sigma }
|
val yErr = List(x.size) { sigma }
|
||||||
|
|
||||||
val chi2 = Fitting.chiSquared(x, y, yErr) { x1 ->
|
val chi2 = Fitting.chiSquared(x, y, yErr) { x1 ->
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package kscience.kmath.prob.distributions
|
package kscience.kmath.stat.distributions
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.UnivariateDistribution
|
import kscience.kmath.stat.UnivariateDistribution
|
||||||
import kscience.kmath.prob.internal.InternalErf
|
import kscience.kmath.stat.internal.InternalErf
|
||||||
import kscience.kmath.prob.samplers.GaussianSampler
|
import kscience.kmath.stat.samplers.GaussianSampler
|
||||||
import kscience.kmath.prob.samplers.NormalizedGaussianSampler
|
import kscience.kmath.stat.samplers.NormalizedGaussianSampler
|
||||||
import kscience.kmath.prob.samplers.ZigguratNormalizedGaussianSampler
|
import kscience.kmath.stat.samplers.ZigguratNormalizedGaussianSampler
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
public inline class NormalDistribution(public val sampler: GaussianSampler) : UnivariateDistribution<Double> {
|
public inline class NormalDistribution(public val sampler: GaussianSampler) : UnivariateDistribution<Double> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package kscience.kmath.prob.internal
|
package kscience.kmath.stat.internal
|
||||||
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package kscience.kmath.prob.internal
|
package kscience.kmath.stat.internal
|
||||||
|
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package kscience.kmath.prob.internal
|
package kscience.kmath.stat.internal
|
||||||
|
|
||||||
import kotlin.math.ln
|
import kotlin.math.ln
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kscience.kmath.prob.internal.InternalUtils
|
import kscience.kmath.stat.internal.InternalUtils
|
||||||
import kotlin.math.ln
|
import kotlin.math.ln
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kscience.kmath.prob.next
|
import kscience.kmath.stat.next
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kscience.kmath.prob.internal.InternalUtils
|
import kscience.kmath.stat.internal.InternalUtils
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.chains.map
|
import kscience.kmath.chains.map
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sampling from a Gaussian distribution with given mean and standard deviation.
|
* Sampling from a Gaussian distribution with given mean and standard deviation.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kotlin.math.exp
|
import kotlin.math.exp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.chains.ConstantChain
|
import kscience.kmath.chains.ConstantChain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kscience.kmath.prob.internal.InternalUtils
|
import kscience.kmath.stat.internal.InternalUtils
|
||||||
import kscience.kmath.prob.next
|
import kscience.kmath.stat.next
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kotlin.math.ln
|
import kotlin.math.ln
|
||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
|
|
||||||
|
@ -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)
|
* Marker interface for a sampler that generates values from an N(0,1)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sampler for the Poisson distribution.
|
* Sampler for the Poisson distribution.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.exp
|
import kotlin.math.exp
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package kscience.kmath.prob.samplers
|
package kscience.kmath.stat.samplers
|
||||||
|
|
||||||
import kscience.kmath.chains.Chain
|
import kscience.kmath.chains.Chain
|
||||||
import kscience.kmath.prob.RandomGenerator
|
import kscience.kmath.stat.RandomGenerator
|
||||||
import kscience.kmath.prob.Sampler
|
import kscience.kmath.stat.Sampler
|
||||||
import kscience.kmath.prob.chain
|
import kscience.kmath.stat.chain
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,7 @@ package kscience.kmath.stat
|
|||||||
import kotlinx.coroutines.flow.take
|
import kotlinx.coroutines.flow.take
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
import kotlinx.coroutines.runBlocking
|
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.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user