本文整理汇总了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;
}