1 package nl.tudelft.simulation.jstats.streams;
2
3 /**
4 * The StreamInterface defines the streams to be used within the JSTATS package. Potential implementations include the pseudo
5 * random stream, the fully one-time random stream, etc.
6 * <p>
7 * Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
8 * for project information <a href="https://simulation.tudelft.nl/dsol/manual/" target="_blank">DSOL Manual</a>. The DSOL
9 * project is distributed under a three-clause BSD-style license, which can be found at
10 * <a href="https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">DSOL License</a>.
11 * </p>
12 * @author <a href="https://github.com/averbraeck" target="_blank"> Alexander Verbraeck</a>
13 * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs </a>
14 */
15 public interface StreamInterface
16 {
17 /**
18 * Return the next pseudo-random, uniformly distributed boolean value.
19 * @return a pseudo-random boolean with 50/50 chance for true or false
20 */
21 boolean nextBoolean();
22
23 /**
24 * Return a pseudo-random number from the stream over the interval (0,1) using this stream, after advancing its state by one
25 * step.
26 * @return the pseudo-random number
27 */
28 double nextDouble();
29
30 /**
31 * Return a pseudo-random number from the stream over the interval (0,1) using this stream, after advancing its state by one
32 * step.
33 * @return the pseudo-random number
34 */
35 float nextFloat();
36
37 /**
38 * Return a pseudo-random number from the stream over using this stream, after advancing its state by one step.
39 * @return the pseudo-random number
40 */
41 int nextInt();
42
43 /**
44 * Return pseudo-random number from the stream between the integers i (inclusive) and j (inclusive).
45 * @param i the minimal value
46 * @param j the maximum value
47 * @return a value between i and j
48 */
49 int nextInt(int i, int j);
50
51 /**
52 * Return a pseudo-random number from the stream over using this stream, after advancing its state by one step.
53 * @return the pseudo-random number
54 */
55 long nextLong();
56
57 /**
58 * Return the seed of the generator.
59 * @return the seed
60 */
61 long getSeed();
62
63 /**
64 * Return the original seed of the generator with which it has been first initialized.
65 * @return the original seed of the generator when it was first initialized
66 */
67 long getOriginalSeed();
68
69 /**
70 * Set the seed of the generator.
71 * @param seed the new seed
72 */
73 void setSeed(long seed);
74
75 /**
76 * Reset the stream to use the original seed with which it was initialized.
77 */
78 void reset();
79 }