本文整理汇总了Java中cern.jet.random.Uniform.staticNextDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Uniform.staticNextDouble方法的具体用法?Java Uniform.staticNextDouble怎么用?Java Uniform.staticNextDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.jet.random.Uniform
的用法示例。
在下文中一共展示了Uniform.staticNextDouble方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uniform_rnd
import cern.jet.random.Uniform; //导入方法依赖的package包/类
public static double uniform_rnd() {
return Uniform.staticNextDouble();
}
示例2: multinomial_rnd
import cern.jet.random.Uniform; //导入方法依赖的package包/类
public static int multinomial_rnd(double[] p, int vSize) {
double sum = 0.0;
double mass = 0.0;
int cc = 0;
int i = 0;
for (i=0;i<vSize;i++) {
sum += p[i];
}
mass = Uniform.staticNextDouble() * sum;
i = 0;
while (true) {
mass -= p[i];
if (mass <= 0.0) break;
i++;
cc++;
}
return cc;
}
示例3: testDenseDoubleMatrix1D
import cern.jet.random.Uniform; //导入方法依赖的package包/类
@Test
public void testDenseDoubleMatrix1D()
{
DenseDoubleMatrix1D a = new DenseDoubleMatrix1D(new double[]{
Uniform.staticNextDouble(),Uniform.staticNextDouble(),Uniform.staticNextDouble()
});
DenseDoubleMatrix1D b = new DenseDoubleMatrix1D(new double[]{
Uniform.staticNextDouble(),Uniform.staticNextDouble(),Uniform.staticNextDouble()
});
DoubleMatrix1D c = a.copy();
FeatureCache cache = new FeatureCache(10);
cache.put(a, null);
assertTrue(cache.containsKey(a));
assertFalse(cache.containsKey(b));
assertTrue(cache.containsKey(c));
}
示例4: next
import cern.jet.random.Uniform; //导入方法依赖的package包/类
/**
* Generate a number according to the given PDF.
* Numbers start at 0 and end at PDF.length-1.
* @return A number generated according to the PDF.
*/
public int next()
{
int pos;
double sum, ran;
// Pick a random index according to the PDF
ran = Uniform.staticNextDouble();
pos = 0;
sum = this.pk[0];
//sum = 0 ;
//System.out.println(" sum : " + sum ) ;
while ( (sum < ran) && (pos < pk.length))
{
// sum += this.pk[pos];
//System.out.println(" pk : " + this.pk[pos] ) ;
pos++;
sum += this.pk[pos];
// // pos++;
//System.out.println("Ran : " + ran + " Pos : " + pos + " sum : " + sum ) ;
}
//pos-- ;
// When running out of indices. Take the last one .
if (pos == pk.length) pos = pk.length-1;
return(pos);
}
示例5: testCorrectValues
import cern.jet.random.Uniform; //导入方法依赖的package包/类
@Test
public static void testCorrectValues()
{
double[] mu = new double[] {0,0};
double[] sigma = new double[] {0.5,0.5};
RadialBasisFunction rbf = new RadialBasisFunction(mu, sigma);
for(int i=0; i<100; i++)
{
double[] x = new double[]{ Uniform.staticNextDouble(), Uniform.staticNextDouble() };
assertEquals(rbf.getValue(x), correctFunction(x, mu, sigma), DELTA);
}
}
示例6: getAction
import cern.jet.random.Uniform; //导入方法依赖的package包/类
/**
* Returns an action for every given state
* With probability of epsilon selectedAction random action and with (1-epsilon)
* the best action
* @param s The state in which an action should be chosen
* @param epsilon probability of taking selectedAction random action
* @return The action to take in state s
*/
public Action getAction(final State state, double epsilon) {
if( Uniform.staticNextDouble() < epsilon ) {
final ActionSet validActions = actionSet.getValidActions(state);
selectedAction = validActions.get( Uniform.staticNextIntFromTo(0,
validActions.size()-1) );
return selectedAction.copy();
}
return getBestAction(state);
}
示例7: getValue
import cern.jet.random.Uniform; //导入方法依赖的package包/类
public double getValue(DoubleMatrix1D x) {
if (Uniform.staticNextDouble() < super.getValue(x))
return 1.0;
return 0.0;
}