本文整理汇总了Java中org.apache.commons.math3.special.Gamma.regularizedGammaQ方法的典型用法代码示例。如果您正苦于以下问题:Java Gamma.regularizedGammaQ方法的具体用法?Java Gamma.regularizedGammaQ怎么用?Java Gamma.regularizedGammaQ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.special.Gamma
的用法示例。
在下文中一共展示了Gamma.regularizedGammaQ方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBlockFrequency
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/**
* Frequency Test with a Block
* <p>
* The focus of the test is the proportion of ones within M-bit
* blocks. The purpose of this test is to determine whether the
* frequency of ones in an M-bit block is approximately block_size/2,
* as would be expected under an assumption of randomness. For block
* size = 1, this test degenerates to test 1, frequency test for RNG.
*/
private void testBlockFrequency(final int[] epsilon, final int M) {
final int n = epsilon.length;
final int N = n / M;
double sum = 0.0;
for (int i = 0; i < N; i++) {
int blockSum = 0;
for (int j = 0; j < M; j++) {
blockSum += epsilon[j + i * M];
}
double pi = (double) blockSum / (double) M;
double v = pi - 0.5;
sum += v * v;
}
double chi_squared = 4.0 * M * sum;
double p_value = Gamma.regularizedGammaQ(N / 2, chi_squared / 2);
assertTrue("RNG test failed, test block frequency.", p_value >= 0.01);
}
示例2: cumulativeProbability
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double cumulativeProbability(int x) {
if (x < 0) {
return 0;
}
if (x == Integer.MAX_VALUE) {
return 1;
}
return Gamma.regularizedGammaQ((double) x + 1, mean, epsilon,
maxIterations);
}
示例3: cumulativeProbability
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double cumulativeProbability(int x)
{
if (x < 0)
{
return 0;
}
if (x == Integer.MAX_VALUE)
{
return 1;
}
return Gamma.regularizedGammaQ((double) x + 1, mean, epsilon, maxIterations);
}
示例4: testSerial
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/**
* Serial Test
* <p>
* The focus of this test is the frequency of all possible overlapping m-bit
* patterns across the entire sequence. The purpose of this test is to determine
* whether the number of occurrences of the 2mm-bit overlapping patterns is
* approximately the same as would be expected for a random sequence. Random
* sequences have uniformity; that is, every m-bit pattern has the same chance
* of appearing as every other m-bit pattern. Note that for m = 1, the Serial
* test is equivalent to the Frequency test of Section 2.1.
*/
private void testSerial(final int[] epsilon, int m) {
double p_value1, p_value2, psim0, psim1, psim2, del1, del2;
psim0 = psi2(epsilon, m);
psim1 = psi2(epsilon, m - 1);
psim2 = psi2(epsilon, m - 2);
del1 = psim0 - psim1;
del2 = psim0 - 2.0 * psim1 + psim2;
p_value1 = Gamma.regularizedGammaQ(Math.pow(2, m - 1) / 2, del1 / 2.0);
p_value2 = Gamma.regularizedGammaQ(Math.pow(2, m - 2) / 2, del2 / 2.0);
assertTrue("RNG test failed(p_value1), test linear complexity.", p_value1 >= 0.01);
assertTrue("RNG test failed(p_value2), test linear complexity.", p_value2 >= 0.01);
}
示例5: testOverlappingTemplateMatchings
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/**
* Overlapping Template Matching Test
* <p>
* The focus of the Overlapping Template Matching test is the number of
* occurrences of pre-specified target strings. Both this test uses an
* m-bit window to search for a specific m-bit pattern. If the pattern
* is not found, the window slides one bit position.
*/
private void testOverlappingTemplateMatchings(final int[] epsilon, final int m) {
int i, k, match;
double w_obs, eta, sum, chi2, p_value, lambda;
int M, N, j, K = 5;
int[] nu = {0, 0, 0, 0, 0, 0}, sequence = new int[m];
double[] pi = {0.143783, 0.139430, 0.137319, 0.124314, 0.106209, 0.348945};
final int n = epsilon.length;
M = 1032;
N = n / M;
for (i = 0; i < m; i++)
sequence[i] = 1;
lambda = (double) (M - m + 1) / Math.pow(2, m);
eta = lambda / 2.0;
sum = 0.0;
for (i = 0; i < K; i++) { /* Compute Probabilities */
pi[i] = pr(i, eta);
sum += pi[i];
}
pi[K] = 1 - sum;
for (i = 0; i < N; i++) {
w_obs = 0;
for (j = 0; j < M - m + 1; j++) {
match = 1;
for (k = 0; k < m; k++) {
if (sequence[k] != epsilon[i * M + j + k])
match = 0;
}
if (match == 1)
w_obs++;
}
if (w_obs <= 4)
nu[(int) w_obs]++;
else
nu[K]++;
}
sum = 0;
chi2 = 0.0; /* Compute Chi Square */
for (i = 0; i < K + 1; i++) {
chi2 += Math.pow((double) nu[i] - (double) N * pi[i], 2) / ((double) N * pi[i]);
sum += nu[i];
}
p_value = Gamma.regularizedGammaQ(K / 2.0, chi2 / 2.0);
assertTrue("RNG test failed, test overlapping template matching.", p_value >= 0.01);
}
示例6: testApproximateEntropy
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/**
* Approximate Entropy Test
* <p>
* As with the Serial test of Section 2.11, the focus of this test is the frequency
* of all possible overlapping m-bit patterns across the entire sequence.
* The purpose of the test is to compare the frequency of overlapping blocks of
* two consecutive/adjacent lengths (m and m+1) against the expected result for
* a random sequence.
*/
private void testApproximateEntropy(final int[] epsilon, int m) {
final int n = epsilon.length;
int i, j, k, r, blockSize, seqLength, powLen, index;
double sum, numOfBlocks, apen, chi_squared, p_value;
double[] ApEn = new double[2];
int[] P;
seqLength = n;
r = 0;
for (blockSize = m; blockSize <= m + 1; blockSize++) {
if (blockSize == 0) {
ApEn[0] = 0.00;
r++;
} else {
numOfBlocks = (double) seqLength;
powLen = (int) Math.pow(2, blockSize + 1) - 1;
P = new int[powLen];
for (i = 1; i < powLen - 1; i++)
P[i] = 0;
for (i = 0; i < numOfBlocks; i++) { /* COMPUTE FREQUENCY */
k = 1;
for (j = 0; j < blockSize; j++) {
k <<= 1;
if ((int) epsilon[(i + j) % seqLength] == 1)
k++;
}
P[k - 1]++;
}
/* DISPLAY FREQUENCY */
sum = 0.0;
index = (int) Math.pow(2, blockSize) - 1;
for (i = 0; i < (int) Math.pow(2, blockSize); i++) {
if (P[index] > 0)
sum += P[index] * Math.log(P[index] / numOfBlocks);
index++;
}
sum /= numOfBlocks;
ApEn[r] = sum;
r++;
}
}
apen = ApEn[0] - ApEn[1];
chi_squared = 2.0 * seqLength * (Math.log(2) - apen);
p_value = Gamma.regularizedGammaQ(Math.pow(2, m - 1), chi_squared / 2.0);
assertTrue("RNG test failed, test approximate entropy.", p_value >= 0.01);
}
示例7: computeQValue
import org.apache.commons.math3.special.Gamma; //导入方法依赖的package包/类
/**
* Compute the q-value of the Chi-squared distribution.
* <p>
* This is the probability of obtaining a value more extreme than this point by chance. A chi-squared value is
* significant if q is higher than the p-value for significance (e.g. 0.05).
*
* @param chiSquared
* the chi squared
* @param degreesOfFreedom
* the degrees of freedom
* @return the q-value
*/
public static double computeQValue(double chiSquared, int degreesOfFreedom)
{
if (chiSquared <= 0)
{
return 1;
}
else
{
return Gamma.regularizedGammaQ(degreesOfFreedom / 2.0, chiSquared / 2.0);
}
}