本文整理汇总了Java中cern.jet.random.Gamma类的典型用法代码示例。如果您正苦于以下问题:Java Gamma类的具体用法?Java Gamma怎么用?Java Gamma使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gamma类属于cern.jet.random包,在下文中一共展示了Gamma类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: dirichlet_rnd
import cern.jet.random.Gamma; //导入依赖的package包/类
public static void dirichlet_rnd(double[] x, double[] alpha, int vSize) {
double sum = 0.0;
double xt = 0.0;
int i = 0;
for(i=0;i<vSize;i++) {
if (alpha[i] <= 0.0) {
xt = 0.0;
} else {
xt = Gamma.staticNextDouble(alpha[i],1.0);
}
if (Double.isNaN(xt)) {
xt = 0.0;
}
x[i] = xt;
sum = sum + x[i];
}
for(i=0;i<vSize;i++) {
x[i] = x[i]/sum;
}
}
开发者ID:seqcode,项目名称:seqcode-core,代码行数:23,代码来源:StatUtil.java
示例2: logDirichletPDF
import cern.jet.random.Gamma; //导入依赖的package包/类
public static double logDirichletPDF(double[] x, double[] alpha, int vSize) {
double alpha_sum = 0.0;
int i = 0;
double lik = 0.0;
for (i=0;i<vSize;i++) {
if (alpha[i] > 0.0) {
if (x[i] > 0.0) {
lik = lik + (alpha[i] - 1.0)*Math.log(x[i]);
}
lik = lik - cern.jet.stat.Gamma.logGamma(alpha[i]);
alpha_sum = alpha_sum + alpha[i];
}
}
lik = lik+cern.jet.stat.Gamma.logGamma(alpha_sum);
return lik;
}
开发者ID:seqcode,项目名称:seqcode-core,代码行数:20,代码来源:StatUtil.java
示例3: logDensity
import cern.jet.random.Gamma; //导入依赖的package包/类
public static double logDensity(double[] alpha, double[] x) {
if(StatUtils.sum(x)!=1) return 0;
double A = org.apache.commons.math3.special.
Gamma.logGamma(StatUtils.sum(alpha));
double B = 0;
for(int i=0; i<alpha.length; i++)
B += org.apache.commons.math3.special.
Gamma.logGamma(alpha[i]);
double C = 0;
for(int i=0; i<x.length; i++)
C += (alpha[i]-1)*Math.log(x[i]);
System.out.println(A);
System.out.println(B);
System.out.println(C);
return A-B+C;
}
开发者ID:c-zhou,项目名称:polyGembler,代码行数:18,代码来源:Dirichlet.java
示例4: setSeed
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
* This resets the generators
* @param seed
*/
public static void setSeed(int seed) {
uniform = new Random(seed);
poisson = new Poisson(1.0, new MersenneTwister(uniform.nextInt()));
gamma = new Gamma(1.0, 5.0, new MersenneTwister(uniform.nextInt()));
gaussian = new Normal(0.0, 1.0, new MersenneTwister(uniform.nextInt()));
}
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:11,代码来源:RNG.java
示例5: NegativeBinomialDistrib
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
* NegativeBinomial (r p parameterization)
* Parameterized as the distribution of the number of failures (X) before the rth success in independent trials
* @param r : Number of successes
* @param p : Probability of success in each trial
*/
public NegativeBinomialDistrib(double r, double p){
this.r = r;
this.p = p;
gamma = new Gamma(1, 1.0, new DRand());
poisson = new Poisson(10, new DRand());
nb = new NegativeBinomialDist(r, p);
}
开发者ID:seqcode,项目名称:seqcode-core,代码行数:14,代码来源:NegativeBinomialDistrib.java
示例6: set
import cern.jet.random.Gamma; //导入依赖的package包/类
public void set(double u){
if(u==Double.POSITIVE_INFINITY){
// throw new RuntimeException("should not set u to pos inf");
// return;
}
for(int i=0; i<g.length; i++){
if(dist[i]>0){
if(g[i]!=null) g[i].setState(dist[i]*u, 1);
g[i] = new Gamma(dist[i]*u, 1, re) ;
}
}
}
开发者ID:c-zhou,项目名称:polyGembler,代码行数:13,代码来源:Dirichlet.java
示例7: GammaDistribution
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
* @param k The shape parameter of the distribution, not negative or zero
* @param theta The scale parameter of the distribution, not negative or zero
* @param engine A uniform random number generator, not null
*/
public GammaDistribution(final double k, final double theta, final RandomEngine engine) {
Validate.isTrue(k > 0, "k must be > 0");
Validate.isTrue(theta > 0, "theta must be > 0");
Validate.notNull(engine);
_gamma = new Gamma(k, 1. / theta, engine);
_k = k;
_theta = theta;
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:14,代码来源:GammaDistribution.java
示例8: GammaDistribution
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
* Constructor
*/
public GammaDistribution(double shape, double scale) {
this.shape = shape;
this.scale = scale;
this.samples = 0;
if (TRY_COLT) {
randomEngine = new MersenneTwister(MathUtils.nextInt());
System.out.println("Colt Gamma(" + shape + "," + scale + ")");
coltGamma = new Gamma(shape, 1.0/scale, randomEngine);
}
}
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:15,代码来源:GammaDistribution.java
示例9: NegativeBinomialDistrib
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
* NegativeBinomial (r p parameterization)
* @param r : Number of successes
* @param p : Probability of success in each trial
*/
public NegativeBinomialDistrib(double r, double p){
this.r = r;
this.p = p;
gamma = new Gamma(1, 1.0, new DRand());
poisson = new Poisson(10, new DRand());
nb = new NegativeBinomialDist(r, p);
}
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:13,代码来源:NegativeBinomialDistrib.java
示例10: Dirichlet
import cern.jet.random.Gamma; //导入依赖的package包/类
public Dirichlet(double[] dist, double u){
super(dist, u);
this.g = new Gamma[dist.length];
set(u);
}
开发者ID:c-zhou,项目名称:polyGembler,代码行数:6,代码来源:Dirichlet.java
示例11: deconv
import cern.jet.random.Gamma; //导入依赖的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);
}
}
}
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:68,代码来源:ConToInt.java
示例12: hyperGeometricPDF
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
* Returns the hypergeometric density probability of number <tt>x</tt>
* when the sample size is <tt>n</tt>, the size of the positive set <tt>s</tt>
* and the population size <tt>N</tt>. <br>
* It works with the gamma function and in log space in an attempt to avoid
* numerical problems.
* @param x # observed successes in the sample
* @param N population size
* @param s # of successes in population (e.g., size of positive set in the population)
* @param n sample size
* @return
*/
public static double hyperGeometricPDF(int x, int N, int s, int n) {
double xd = (double) x;
double Nd = (double) N;
double sd = (double) s;
double nd = (double) n;
double kx = cern.jet.stat.Gamma.logGamma(sd+1)-cern.jet.stat.Gamma.logGamma(x+1)-cern.jet.stat.Gamma.logGamma(sd-x+1);
double mn = cern.jet.stat.Gamma.logGamma(Nd+1)-cern.jet.stat.Gamma.logGamma(nd+1)-cern.jet.stat.Gamma.logGamma(Nd-nd+1);
double mknx = cern.jet.stat.Gamma.logGamma(Nd-sd+1)-cern.jet.stat.Gamma.logGamma(nd-x+1)-cern.jet.stat.Gamma.logGamma(Nd-sd-(nd-x)+1);
return Math.exp(kx + mknx - mn);
}
开发者ID:seqcode,项目名称:seqcode-core,代码行数:23,代码来源:StatUtil.java
示例13: getGammaGenerator
import cern.jet.random.Gamma; //导入依赖的package包/类
/**
*
* @return Gamma distribution RNG
*/
public static Gamma getGammaGenerator() {
return gamma;
}
开发者ID:LEB-EPFL,项目名称:SASS,代码行数:8,代码来源:RNG.java
注:本文中的cern.jet.random.Gamma类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论