1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.rng.sampling.distribution;
18
19 import org.apache.commons.rng.UniformRandomProvider;
20 import org.apache.commons.rng.sampling.RandomAssert;
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.Test;
23
24
25
26
27 class InverseTransformParetoSamplerTest {
28
29
30
31 @Test
32 void testConstructorThrowsWithZeroScale() {
33 final UniformRandomProvider rng = RandomAssert.seededRNG();
34 final double scale = 0;
35 final double shape = 1;
36 Assertions.assertThrows(IllegalArgumentException.class,
37 () -> InverseTransformParetoSampler.of(rng, scale, shape));
38 }
39
40
41
42
43 @Test
44 void testConstructorThrowsWithZeroShape() {
45 final UniformRandomProvider rng = RandomAssert.seededRNG();
46 final double scale = 1;
47 final double shape = 0;
48 Assertions.assertThrows(IllegalArgumentException.class,
49 () -> InverseTransformParetoSampler.of(rng, scale, shape));
50 }
51
52
53
54
55 @Test
56 void testSharedStateSampler() {
57 final UniformRandomProvider rng1 = RandomAssert.seededRNG();
58 final UniformRandomProvider rng2 = RandomAssert.seededRNG();
59 final double scale = 1.23;
60 final double shape = 4.56;
61 final SharedStateContinuousSampler sampler1 =
62 InverseTransformParetoSampler.of(rng1, scale, shape);
63 final SharedStateContinuousSampler sampler2 = sampler1.withUniformRandomProvider(rng2);
64 RandomAssert.assertProduceSameSequence(sampler1, sampler2);
65 }
66 }