本文整理汇总了Java中cern.jet.random.engine.RandomEngine.makeDefault方法的典型用法代码示例。如果您正苦于以下问题:Java RandomEngine.makeDefault方法的具体用法?Java RandomEngine.makeDefault怎么用?Java RandomEngine.makeDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.jet.random.engine.RandomEngine
的用法示例。
在下文中一共展示了RandomEngine.makeDefault方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGeometricDistribution
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
@Test
public void testGeometricDistribution()
{
StreamSummary<Integer> vs = new StreamSummary<Integer>(10);
RandomEngine re = RandomEngine.makeDefault();
for (int i = 0; i < NUM_ITERATIONS; i++)
{
int z = Distributions.nextGeometric(0.25, re);
vs.add(z);
}
List<CountEntry<Integer>> top = vs.peek(5);
System.out.println("Geometric:");
for (CountEntry<Integer> e : top)
{
System.out.println(e);
}
CountEntry<Integer> tippyTop = top.get(0);
assertEquals(0, (int) tippyTop.getItem());
System.out.println(vs);
}
示例2: testGeometricDistribution
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
@Test
public void testGeometricDistribution() {
ConcurrentStreamSummary<Integer> vs = new ConcurrentStreamSummary<Integer>(10);
RandomEngine re = RandomEngine.makeDefault();
for (int i = 0; i < NUM_ITERATIONS; i++) {
int z = Distributions.nextGeometric(0.25, re);
vs.add(z);
}
List<CountEntry<Integer>> top = vs.peek(5);
System.out.println("Geometric:");
for (CountEntry<Integer> e : top) {
System.out.println(e.getItem() + "\t" + e.getFrequency());
}
CountEntry<Integer> tippyTop = top.get(0);
assertEquals(0, (int) tippyTop.getItem());
System.out.println(vs);
}
示例3: testZipfianDistribution
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
@Test
public void testZipfianDistribution()
{
RandomEngine re = RandomEngine.makeDefault();
for (int i = 0; i < NUM_ITERATIONS; i++)
{
int z = Distributions.nextZipfInt(1.2D, re);
vs.add(z);
}
List<CountEntry<Integer>> top = vs.peek(5);
System.out.println("Zipfian:");
for (CountEntry<Integer> e : top)
{
System.out.println(e);
}
CountEntry<Integer> tippyTop = top.get(0);
assertTrue(tippyTop.getItem() < 3);
}
示例4: testGeometricDistribution
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
@Test
public void testGeometricDistribution()
{
RandomEngine re = RandomEngine.makeDefault();
for (int i = 0; i < NUM_ITERATIONS; i++)
{
int z = Distributions.nextGeometric(0.25, re);
vs.add(z);
}
List<CountEntry<Integer>> top = vs.peek(5);
System.out.println("Geometric:");
for (CountEntry<Integer> e : top)
{
System.out.println(e);
}
CountEntry<Integer> tippyTop = top.get(0);
assertTrue(tippyTop.getItem() < 3);
}
示例5: run
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
public void run() {
Binomial binomial = new Binomial(100, .01, RandomEngine.makeDefault());
for (int i = first; i < matrices.size(); i += skip) {
WeightMatrix mi = matrices.get(i);
double maxscorei = mi.getMaxScore();
System.err.println("matrix one " + i);
for (int j = i + 1; j < matrices.size(); j++) {
WeightMatrix mj = matrices.get(j);
double maxscorej = mj.getMaxScore();
double percenti = cutoffpercent - step;
while (percenti <= 1) {
percenti += step;
double ti = percenti * maxscorei;
double percentj = cutoffpercent - step;
while (percentj <= 1) {
percentj += step;
double tj = percentj * maxscorej;
int fgcount = count(i,j,ti,tj,fghits);
double thetaone = ((double)fgcount) / ((double)fgsize);
if (fgsize <= 0 || thetaone < minfrac) {
continue;
}
int bgcount = count(i,j,ti,tj,bghits);
double thetatwo = ((double)bgcount) / ((double)bgsize);
if (thetatwo < minfrac ||
thetatwo <= 0) {
continue;
}
if (thetatwo > maxbackfrac) {
continue;
}
double fc = Math.log(thetaone / thetatwo);
if (Math.abs(fc) < Math.abs(Math.log(minfoldchange))) {
continue;
}
binomial.setNandP(fgsize, thetatwo);
double pval = 1 - binomial.cdf(fgcount);
if (pval <= filtersig) {
CombResult result = new CombResult();
result.matrices.add(mi);
result.matrices.add(mj);
result.sizeone = fgsize;
result.sizetwo = bgsize;
result.pval = pval;
result.percents.add(percenti);
result.percents.add(percentj);
result.cutoffs.add(ti);
result.cutoffs.add(tj);
result.countone = fgcount;
result.counttwo = bgcount;
result.logfoldchange = fc;
result.freqone = thetaone;
result.freqtwo = thetatwo;
if (result.pval <= filtersig &&
Math.abs(result.logfoldchange) >= Math.abs(Math.log(minfoldchange)) &&
(result.freqtwo <= maxbackfrac) &&
(result.freqone >= minfrac || result.freqtwo >= minfrac)) {
results.add(result);
}
}
}
}
}
}
}
示例6: testRandomEngine
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
@Test
public void testRandomEngine()
{
int[] maxcounts = new int[10];
int[] counts = new int[20];
RandomEngine re = RandomEngine.makeDefault();
for (int i = 0; i < NUM_ITERATIONS; i++)
{
// int z = Distributions.nextZipfInt(1.2D, re);
int z = Distributions.nextGeometric(0.25, re);
if (z > Integer.MAX_VALUE - 9)
{
maxcounts[Integer.MAX_VALUE - z]++;
}
if (z < 20)
{
counts[z]++;
}
}
for (int i = 0; i < 20; i++)
{
System.out.println(i + ": " + counts[i]);
}
for (int i = 9; i >= 0; i--)
{
System.out.println((Integer.MAX_VALUE - i) + ": " + maxcounts[i]);
}
}
示例7: DiscriminativeKmers
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
public DiscriminativeKmers () {
seqgen = new SequenceGenerator();
binomial = new Binomial(100, .01, RandomEngine.makeDefault());
}
示例8: deconv
import cern.jet.random.engine.RandomEngine; //导入方法依赖的package包/类
public void deconv() {
if (nogamma) {
/* deconvolve the actual data: convolution of two gammas is a gamma of half the size
*/
deconv = new double[smoothed.length / 2 + 1];
for (int i = 0; i < deconv.length; i++) {
deconv[i] = 0;
}
for (int i = 0; i < smoothed.length; i++) {
deconv[i / 2] += smoothed[i];
}
double max = 0;
for (int i = 0; i < deconv.length; i++) {
if (deconv[i] > max) {
max = deconv[i];
}
}
for (int i = 0; i < deconv.length; i++) {
deconv[i] /= max;
}
} else {
double mean, var;
int min = 0;
if (!Double.isNaN(alpha) && !Double.isNaN(beta)) {
mean = alpha * beta;
var = alpha * beta * beta;
} else {
mean = 0;
/* The gamma distribution isn't a good fit if it doesn't
start at ~0. So find the first index at which there's much
probability mass and then effectively shift smoothed[] by
that much
*/
for (int i = 0; i < smoothed.length; i++) {
if (smoothed[i] < .00000001) {
smoothed[i] = 0;
min = i;
} else {
break;
}
}
for (int i = min; i < smoothed.length; i++) {
System.err.println(String.format("smoothed[%d] = %.20f", i, smoothed[i]));
mean += smoothed[i] * (i - min);
}
var = 0;
for (int i = min; i < smoothed.length; i++) {
var += smoothed[i] * (i - min - mean) * (i - min - mean);
}
beta = var / mean;
alpha = mean / beta;
}
System.err.println(String.format("min %d, mean %f, var %f, alpha %f, beta %f",
min, mean, var, alpha, beta));
alpha = alpha / 2; // do the deconvolution
min /= 2;
deconv = new double[maxdist];
for (int i = 0; i < min; i++) {
deconv[i] = 0;
}
RandomEngine engine = RandomEngine.makeDefault();
Gamma gamma = new Gamma(alpha, beta, engine);
for (int i = min; i < deconv.length; i++) {
deconv[i] = gamma.pdf(i - min);
}
}
}