Synthia
Generic and flexible data structure generator
GaussianFloat.java
Go to the documentation of this file.
1 /*
2  Synthia, a data structure generator
3  Copyright (C) 2019-2020 Laboratoire d'informatique formelle
4  Université du Québec à Chicoutimi, Canada
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 package ca.uqac.lif.synthia.random;
20 
21 import ca.uqac.lif.synthia.Picker;
22 
23 /**
24  * Produces a {@link float} picked from a Gaussian probability distribution.
25  * @author Sylvain Hallé
26  * @ingroup API
27  */
28 public class GaussianFloat extends RandomPicker<Float>
29 {
30  @Override
31  public Float pick()
32  {
33  return ((Double) m_random.nextGaussian()).floatValue();
34  }
35 
36  @Override
37  public Picker<Float> duplicate(boolean with_state)
38  {
39  GaussianFloat gf = new GaussianFloat();
40  gf.m_seed = m_seed;
41  gf.m_random = this.m_random.Duplicate();
42 
43  if (!with_state)
44  {
45  gf.reset();
46  }
47  return gf;
48  }
49 
50 }
ca.uqac.lif.synthia.Picker
Picks an object.
Definition: Picker.java:36
ca.uqac.lif.synthia.random.GaussianFloat.pick
Float pick()
Definition: GaussianFloat.java:31
ca.uqac
ca.uqac.lif.synthia
Definition: Bounded.java:19
ca.uqac.lif.synthia.random.GaussianFloat
Produces a float picked from a Gaussian probability distribution.
Definition: GaussianFloat.java:28
ca.uqac.lif
ca.uqac.lif.synthia.random.Random.nextGaussian
synchronized double nextGaussian()
Returns the next pseudorandom, Gaussian ("normally") distributed.
Definition: Random.java:603
ca.uqac.lif.synthia.random.RandomPicker.reset
void reset()
Puts the picker back into its initial state.
Definition: RandomPicker.java:68
ca.uqac.lif.synthia.random.Random.Duplicate
Random Duplicate()
Creates a new instance of the class with the exact same internal states that the original one.
Definition: Random.java:123
ca
ca.uqac.lif.synthia.random.RandomPicker
Picks an object based on the value of a random number generator.
Definition: RandomPicker.java:39
ca.uqac.lif.synthia.random.GaussianFloat.duplicate
Picker< Float > duplicate(boolean with_state)
Definition: GaussianFloat.java:37
ca.uqac.lif.synthia.random.RandomPicker.m_seed
int m_seed
Definition: RandomPicker.java:49
ca.uqac.lif.synthia.random.RandomPicker< Float >::m_random
transient Random m_random
Definition: RandomPicker.java:47