Dev #280
@ -1,24 +1,21 @@
|
|||||||
package space.kscience.kmath.stat
|
package space.kscience.kmath.stat
|
||||||
|
|
||||||
import kotlinx.coroutines.flow.take
|
|
||||||
import kotlinx.coroutines.flow.toList
|
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import space.kscience.kmath.samplers.GaussianSampler
|
import space.kscience.kmath.samplers.GaussianSampler
|
||||||
import space.kscience.kmath.structures.asBuffer
|
|
||||||
|
|
||||||
internal class CommonsDistributionsTest {
|
internal class CommonsDistributionsTest {
|
||||||
@Test
|
@Test
|
||||||
fun testNormalDistributionSuspend() = runBlocking {
|
fun testNormalDistributionSuspend() = runBlocking {
|
||||||
val distribution = GaussianSampler(7.0, 2.0)
|
val distribution = GaussianSampler(7.0, 2.0)
|
||||||
val generator = RandomGenerator.default(1)
|
val generator = RandomGenerator.default(1)
|
||||||
val sample = distribution.sample(generator).take(1000).toList().toDoubleArray().asBuffer()
|
val sample = distribution.sample(generator).nextBuffer(1000)
|
||||||
Assertions.assertEquals(7.0, Mean.double(sample), 0.2)
|
Assertions.assertEquals(7.0, Mean.double(sample), 0.2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNormalDistributionBlocking() {
|
fun testNormalDistributionBlocking() {
|
||||||
val distribution = GaussianSampler(7.0, 2.0)
|
val distribution = GaussianSampler(7.0, 2.0)
|
||||||
val generator = RandomGenerator.default(1)
|
val generator = RandomGenerator.default(1)
|
||||||
val sample = distribution.sample(generator).nextBufferBlocking(1000)
|
val sample = distribution.sample(generator).nextBufferBlocking(1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user