本文整理匯總了Java中org.apache.commons.math3.random.RandomGenerator.nextGaussian方法的典型用法代碼示例。如果您正苦於以下問題:Java RandomGenerator.nextGaussian方法的具體用法?Java RandomGenerator.nextGaussian怎麽用?Java RandomGenerator.nextGaussian使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.random.RandomGenerator
的用法示例。
在下文中一共展示了RandomGenerator.nextGaussian方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: normallyRandomInitialParams
import org.apache.commons.math3.random.RandomGenerator; //導入方法依賴的package包/類
public void normallyRandomInitialParams(double mu, double sigma) {
RandomGenerator rg = RandomGeneratorFactory.createRandomGenerator(new Random(System.currentTimeMillis()));
_W = new double[layerNum - 1][][];
for (int l = 0; l < layerNum - 1; l++) {
_W[l] = new double[activationLayerNum[l + 1]][];
for (int i = 0; i < activationLayerNum[l + 1]; i++) {
_W[l][i] = new double[activationLayerNum[l]];
for (int j = 0; j < activationLayerNum[l]; j++) {
// 將原始為mu為0.5,3sigma為0.5的正態分布,轉移到mu,sigma為此處設置的正態分布的隨機值
_W[l][i][j] = (rg.nextGaussian() - 0.5 + mu) * 6.0 * sigma;
}
}
}
_B = new double[layerNum - 1];
for (int l = 0; l < layerNum - 1; l++) {
_B[l] = (rg.nextGaussian() - 0.5 + mu) * 6.0 * sigma;
}
}
示例2: randomVectorF
import org.apache.commons.math3.random.RandomGenerator; //導入方法依賴的package包/類
/**
* @param features dimension of vector
* @param random random number generator
* @return vector whose direction from the origin is chosen uniformly at random, but which is not normalized
*/
public static float[] randomVectorF(int features, RandomGenerator random) {
float[] vector = new float[features];
for (int i = 0; i < features; i++) {
vector[i] = (float) random.nextGaussian();
}
return vector;
}
示例3: generate
import org.apache.commons.math3.random.RandomGenerator; //導入方法依賴的package包/類
@Override
public Pair<String,String> generate(int id, RandomGenerator random) {
return new Pair<>(Integer.toString(id),
id + "," +
random.nextInt(100) + ',' +
random.nextBoolean() + ',' +
random.nextGaussian());
}
示例4: normal
import org.apache.commons.math3.random.RandomGenerator; //導入方法依賴的package包/類
public static double normal(double mean, double sd) {
RandomGenerator rg = getInstance().get();
return rg.nextGaussian()*sd+mean;
}
示例5: generateData
import org.apache.commons.math3.random.RandomGenerator; //導入方法依賴的package包/類
protected static double generateData(final double trueStandardDeviation, final Double cr, final RandomGenerator rng) {
return cr + rng.nextGaussian() * trueStandardDeviation;
}