Synthia
Generic and flexible data structure generator
Variation4.java
Go to the documentation of this file.
1 /*
2  Synthia, a data structure generator
3  Copyright (C) 2019-2021 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 examples.hypersphere;
20 
23 import ca.uqac.lif.synthia.util.Choice;
25 import ca.uqac.lif.synthia.util.Tick;
27 import examples.util.Utilities;
28 
29 /**
30  * Generates two-dimensional points lying along an oblique line.
31  * The points are generated by composing pickers as in the following diagram:
32  * <p>
33  * <img src="./doc-files/hypersphere/Variation4.png" alt="Diagram">
34  * <p>
35  * The angle for each point is fixed to 3&pi;/2, and the radius is picked
36  * according to a normal distribution, resulting in points clustered close to
37  * the origin.
38  *
39  * @ingroup Examples
40  */
41 public class Variation4
42 {
43  @SuppressWarnings("unchecked")
44  public static void main(String[] args)
45  {
46  RandomInteger ri = new RandomInteger(0, 2).setSeed(42);
47  Constant<Float> c1 = new Constant<Float>(1 / 6f);
48  Tick radius = new Tick(ri, c1);
49  RandomFloat rf = new RandomFloat().setSeed(42);
50  Choice<Double> start = new Choice<Double>(rf)
51  .add(0d, 0.25).add(Math.PI / 2, 0.25).add(Math.PI, 0.25).add(3 * Math.PI / 2, 0.25);
52  Constant<Float> c2 = new Constant<Float>(1 / 6f);
53  Tick angle = new Tick(start, c2);
54  HyperspherePicker hp = new HyperspherePicker(radius, angle);
55  for (int i = 0; i < 100; i++)
56  {
57  Utilities.print(System.out, hp.pick());
58  }
59  }
60 
61 }
ca.uqac.lif.synthia.util
Miscellaneous pickers performing various functions.
Definition: ArrayPicker.java:19
ca.uqac.lif.synthia.vector.HyperspherePicker.pick
float[] pick()
Picks an object.
Definition: HyperspherePicker.java:97
ca.uqac.lif.synthia.vector
Pickers generating multi-dimensional numerical vectors.
Definition: HyperspherePicker.java:19
ca.uqac
examples.util
Definition: package-info.java:1
ca.uqac.lif.synthia.random
Pickers that produce pseudo-random objects such as numbers.
Definition: AffineTransform.java:19
ca.uqac.lif.synthia
Definition: Bounded.java:19
ca.uqac.lif.synthia.util.Constant
Picker that returns the same object every time.
Definition: Constant.java:37
ca.uqac.lif.synthia.vector.HyperspherePicker
Generates n-dimensional vectors with a given modulus.
Definition: HyperspherePicker.java:42
examples.util.Utilities
Object providing a few utility methods to simplify the examples in this project.
Definition: Utilities.java:30
ca.uqac.lif.synthia.random.RandomFloat.setSeed
RandomFloat setSeed(int seed)
Definition: RandomFloat.java:85
ca.uqac.lif
ca.uqac.lif.synthia.util.Choice.add
Choice< T > add(ProbabilityChoice< T > pc)
Adds an object-probability association.
Definition: Choice.java:72
ca.uqac.lif.synthia.random.RandomInteger.setSeed
RandomInteger setSeed(int seed)
Definition: RandomInteger.java:102
ca.uqac.lif.synthia.random.RandomInteger
Picks an integer uniformly in an interval.
Definition: RandomInteger.java:31
ca.uqac.lif.synthia.util.Tick
Generates a sequence of monotonically increasing numerical values.
Definition: Tick.java:51
ca
examples
ca.uqac.lif.synthia.random.RandomFloat
Picks a floating point number uniformly in an interval.
Definition: RandomFloat.java:30
ca.uqac.lif.synthia.util.Choice
Picks an element from a collection, where the probability of picking each element can be user-defined...
Definition: Choice.java:44
examples.util.Utilities.print
static void print(PrintStream ps, Object o)
Prints an object to a print stream.
Definition: Utilities.java:37
examples.hypersphere.Variation4
Generates two-dimensional points lying along an oblique line.
Definition: Variation4.java:41
examples.hypersphere.Variation4.main
static void main(String[] args)
Definition: Variation4.java:44