mirror of https://github.com/jlizier/jidt
177 lines
6.5 KiB
Java
177 lines
6.5 KiB
Java
/*
|
|
* Java Information Dynamics Toolkit (JIDT)
|
|
* Copyright (C) 2017, Joseph T. Lizier
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/*
|
|
* This class was originally distributed as part of the Apache Commons
|
|
* Math3 library (3.6.1), under the Apache License Version 2.0, which is
|
|
* copied below. This Apache 2 software is now included as a derivative
|
|
* work in the GPLv3 licensed JIDT project, as per:
|
|
* http://www.apache.org/licenses/GPL-compatibility.html
|
|
*
|
|
* The original Apache source code has been modified as follows:
|
|
* -- We have modified package names to sit inside the JIDT structure.
|
|
*/
|
|
|
|
/*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
* (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package infodynamics.utils.commonsmath3.random;
|
|
|
|
|
|
/**
|
|
* Interface extracted from <code>java.util.Random</code>. This interface is
|
|
* implemented by {@link AbstractRandomGenerator}.
|
|
*
|
|
* @since 1.1
|
|
*/
|
|
public interface RandomGenerator {
|
|
|
|
/**
|
|
* Sets the seed of the underlying random number generator using an
|
|
* <code>int</code> seed.
|
|
* <p>Sequences of values generated starting with the same seeds
|
|
* should be identical.
|
|
* </p>
|
|
* @param seed the seed value
|
|
*/
|
|
void setSeed(int seed);
|
|
|
|
/**
|
|
* Sets the seed of the underlying random number generator using an
|
|
* <code>int</code> array seed.
|
|
* <p>Sequences of values generated starting with the same seeds
|
|
* should be identical.
|
|
* </p>
|
|
* @param seed the seed value
|
|
*/
|
|
void setSeed(int[] seed);
|
|
|
|
/**
|
|
* Sets the seed of the underlying random number generator using a
|
|
* <code>long</code> seed.
|
|
* <p>Sequences of values generated starting with the same seeds
|
|
* should be identical.
|
|
* </p>
|
|
* @param seed the seed value
|
|
*/
|
|
void setSeed(long seed);
|
|
|
|
/**
|
|
* Generates random bytes and places them into a user-supplied
|
|
* byte array. The number of random bytes produced is equal to
|
|
* the length of the byte array.
|
|
*
|
|
* @param bytes the non-null byte array in which to put the
|
|
* random bytes
|
|
*/
|
|
void nextBytes(byte[] bytes);
|
|
|
|
/**
|
|
* Returns the next pseudorandom, uniformly distributed <code>int</code>
|
|
* value from this random number generator's sequence.
|
|
* All 2<font size="-1"><sup>32</sup></font> possible {@code int} values
|
|
* should be produced with (approximately) equal probability.
|
|
*
|
|
* @return the next pseudorandom, uniformly distributed <code>int</code>
|
|
* value from this random number generator's sequence
|
|
*/
|
|
int nextInt();
|
|
|
|
/**
|
|
* Returns a pseudorandom, uniformly distributed {@code int} value
|
|
* between 0 (inclusive) and the specified value (exclusive), drawn from
|
|
* this random number generator's sequence.
|
|
*
|
|
* @param n the bound on the random number to be returned. Must be
|
|
* positive.
|
|
* @return a pseudorandom, uniformly distributed {@code int}
|
|
* value between 0 (inclusive) and n (exclusive).
|
|
* @throws IllegalArgumentException if n is not positive.
|
|
*/
|
|
int nextInt(int n);
|
|
|
|
/**
|
|
* Returns the next pseudorandom, uniformly distributed <code>long</code>
|
|
* value from this random number generator's sequence. All
|
|
* 2<font size="-1"><sup>64</sup></font> possible {@code long} values
|
|
* should be produced with (approximately) equal probability.
|
|
*
|
|
* @return the next pseudorandom, uniformly distributed <code>long</code>
|
|
*value from this random number generator's sequence
|
|
*/
|
|
long nextLong();
|
|
|
|
/**
|
|
* Returns the next pseudorandom, uniformly distributed
|
|
* <code>boolean</code> value from this random number generator's
|
|
* sequence.
|
|
*
|
|
* @return the next pseudorandom, uniformly distributed
|
|
* <code>boolean</code> value from this random number generator's
|
|
* sequence
|
|
*/
|
|
boolean nextBoolean();
|
|
|
|
/**
|
|
* Returns the next pseudorandom, uniformly distributed <code>float</code>
|
|
* value between <code>0.0</code> and <code>1.0</code> from this random
|
|
* number generator's sequence.
|
|
*
|
|
* @return the next pseudorandom, uniformly distributed <code>float</code>
|
|
* value between <code>0.0</code> and <code>1.0</code> from this
|
|
* random number generator's sequence
|
|
*/
|
|
float nextFloat();
|
|
|
|
/**
|
|
* Returns the next pseudorandom, uniformly distributed
|
|
* <code>double</code> value between <code>0.0</code> and
|
|
* <code>1.0</code> from this random number generator's sequence.
|
|
*
|
|
* @return the next pseudorandom, uniformly distributed
|
|
* <code>double</code> value between <code>0.0</code> and
|
|
* <code>1.0</code> from this random number generator's sequence
|
|
*/
|
|
double nextDouble();
|
|
|
|
/**
|
|
* Returns the next pseudorandom, Gaussian ("normally") distributed
|
|
* <code>double</code> value with mean <code>0.0</code> and standard
|
|
* deviation <code>1.0</code> from this random number generator's sequence.
|
|
*
|
|
* @return the next pseudorandom, Gaussian ("normally") distributed
|
|
* <code>double</code> value with mean <code>0.0</code> and
|
|
* standard deviation <code>1.0</code> from this random number
|
|
* generator's sequence
|
|
*/
|
|
double nextGaussian();
|
|
}
|