Package de.gsi.math
Class TMath
- java.lang.Object
-
- de.gsi.math.TMathConstants
-
- de.gsi.math.TMath
-
public class TMath extends TMathConstants
-
-
Constructor Summary
Constructors Constructor Description TMath()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static doubleBesselI(int n, double x)static doubleBesselI0(double x)static doubleBesselI1(double x)static doubleBesselJ0(double x)static doubleBesselJ1(double x)static doubleBesselK(int n, double x)static doubleBesselK0(double x)static doubleBesselK1(double x)static doubleBesselY0(double x)static doubleBesselY1(double x)static doubleBeta(double p, double q)static doubleBetaCf(double x, double a, double b)static doubleBetaDist(double x, double p, double q)Computes the probability density function of the Beta distribution (the distribution function is computed in BetaDistI).static doubleBetaDistI(double x, double p, double q)static doubleBetaIncomplete(double x, double a, double b)static longBinarySearch(double[] array, int length, double value)Binary search in an array of n values to locate value.static longBinarySearch(float[] array, int length, float value)Binary search in an array of n values to locate value.static longBinarySearch(int[] array, int length, int value)Binary search in an array of n values to locate value.static longBinarySearch(long[] array, int length, long value)Binary search in an array of n values to locate value.static longBinarySearch(short[] array, int length, short value)Binary search in an array of n values to locate value.static doubleBinomial(int n, int k)static doubleBinomialI(double p, int n, int k)static doubleBreitWigner(double x, double mean, double gamma)Calculate a Breit Wigner function with mean and gamma.static doubleCauchyDist(double x, double t, double s)Computes the density of Cauchy distribution at point x The Cauchy distribution, also called Lorentzian distribution, is a continuous distribution describing resonance behavior The mean and standard deviation of the Cauchy distribution are undefined.static doubleChisquareQuantile(double p, double ndf)Evaluate the quantiles of the chi-squared probability distribution function.static doubleCorrelationCoefficient(double[] x, double[] y, double[] w)Calculate weighted correlation coefficient x y data and weights w as doublestatic doubleCovariance(double[] xx, double[] yy, double[] ww)calculated weighted covariance xx and yy with weights wwstatic double[]Cross(double[] v1, double[] v2, double[] out)Calculate the Cross Product of two vectors:static float[]Cross(float[] v1, float[] v2, float[] out)Calculate the Cross Product of two vectors:static double[]Difference(double[] a, double[] b)static double[]Difference(double[] a, double[] b, int length)computes the difference between vectorsstatic float[]Difference(float[] a, float[] b)static float[]Difference(float[] a, float[] b, int length)computes the difference between vectorsstatic int[]Difference(int[] a, int[] b)static int[]Difference(int[] a, int[] b, int length)computes the difference between vectorsstatic long[]Difference(long[] a, long[] b)static long[]Difference(long[] a, long[] b, int length)computes the difference between vectorsstatic short[]Difference(short[] a, short[] b)static short[]Difference(short[] a, short[] b, int length)computes the difference between vectorsstatic doubleDiLog(double x)The DiLogarithm function Code translated by from CERNLIB DILOG function C332static doubleeffectiveSampleNumber(double[] ww)static doubleErf(double x)Computation of the error function erf(x).static doubleErfc(double x)Compute the complementary error function erfc(x).static doubleErfInverse(double x)returns the inverse error functionstatic doubleFactorial(int n)Compute factorial(n).static doubleFDist(double F, double N, double M)static doubleFDistI(double F, double N, double M)static doubleFreq(double x)Computation of the normal frequency function freq(x).static doubleGamCf(double a, double x)Computation of the incomplete gamma function P(a,x) via its continued fraction representation.static doubleGamma(double z)Computation of gamma(z) for all z>0.static doubleGamma(double a, double x)Computation of the normalized lower incomplete gamma function P(a,x) as defined in the Handbook of Mathematical Functions by Abramowitz and Stegun, formula 6.5.1 on page 260 .static doubleGammaDist(double x, double gamma, double mu, double beta)static doubleGamSer(double a, double x)Computation of the incomplete gamma function P(a,x) via its series representation.static doubleGauss(double x, double mean, double sigma, boolean norm)Calculate a Gaussian function with mean and sigma.static doubleGeometricMean(double[] data)static doubleGeometricMean(double[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}static floatGeometricMean(float[] data)static floatGeometricMean(float[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}static intGeometricMean(int[] data)static intGeometricMean(int[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}static longGeometricMean(long[] data)static longGeometricMean(long[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}static shortGeometricMean(short[] data)static shortGeometricMean(short[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}static booleanIsInside(double xp, double yp, int np, double[] x, double[] y)Function which returns true if point xp,yp lies inside the polygon defined by the np points in arrays x and y, false otherwise NOTE that the polygon must be a closed polygon (1st and last point must be identical).static booleanIsInside(float xp, float yp, int np, float[] x, float[] y)Function which returns true if point xp,yp lies inside the polygon defined by the np points in arrays x and y, false otherwise NOTE that the polygon must be a closed polygon (1st and last point must be identical).static booleanIsInside(int xp, int yp, int np, int[] x, int[] y)Function which returns true if point xp,yp lies inside the polygon defined by the np points in arrays x and y, false otherwise NOTE that the polygon must be a closed polygon (1st and last point must be identical).doubleKolmogorovProb(double z)Calculates the Kolmogorov distribution function, which gives the probability that Kolmogorov's test statistic will exceed the value z assuming the null hypothesis.doubleKolmogorovTest(int na, double[] a, int nb, double[] b, java.lang.String option)static doubleLandau(double x, double mpv, double sigma, boolean norm)The LANDAU function with mpv(most probable value) and sigma.static doubleLandauI(double x)static doubleLaplaceDist(double x, double alpha, double beta)static doubleLaplaceDistI(double x, double alpha, double beta)static doubleLnGamma(double z)Computation of ln[gamma(z)] for all z>0.static longLocationMaximum(double[] a, int length)static longLocationMaximum(float[] a, int length)static longLocationMaximum(int[] a, int length)static longLocationMaximum(long[] a, int length)static longLocationMinimum(double[] a, int length)static longLocationMinimum(float[] a, int length)static longLocationMinimum(int[] a, int length)static longLocationMinimum(long[] a, int length)static longLocationMinimum(short[] a, int length)static doubleLogNormal(double x, double sigma, double theta, double m)Computes the density of LogNormal distribution at point x.static voidmain(java.lang.String[] argv)static doubleMaximum(double[] data)static doubleMaximum(double[] data, int length)static floatMaximum(float[] data)static floatMaximum(float[] data, int length)static intMaximum(int[] data)static intMaximum(int[] data, int length)static longMaximum(long[] data)static longMaximum(long[] data, int length)static shortMaximum(short[] data)static shortMaximum(short[] data, int length)static doubleMean(double[] data)static doubleMean(double[] data, int length)static floatMean(float[] data)static floatMean(float[] data, int length)static intMean(int[] data)static intMean(int[] data, int length)static longMean(long[] data)static longMean(long[] data, int length)static shortMean(short[] data)static shortMean(short[] data, int length)static doubleMedian(double[] data)static doubleMedian(double[] data, int length)static floatMedian(float[] data)static floatMedian(float[] data, int length)static intMedian(int[] data)static intMedian(int[] data, int length)static longMedian(long[] data)static longMedian(long[] data, int length)static shortMedian(short[] data)static shortMedian(short[] data, int length)static doubleMinimum(double[] data)static doubleMinimum(double[] data, int length)static floatMinimum(float[] data)static floatMinimum(float[] data, int length)static intMinimum(int[] data)static intMinimum(int[] data, int length)static longMinimum(long[] data)static longMinimum(long[] data, int length)static shortMinimum(short[] data)static shortMinimum(short[] data, int length)static double[]Normal2Plane(double[] p1, double[] p2, double[] p3, double[] normal)Calculate a normal vector of a plane.static float[]Normal2Plane(float[] p1, float[] p2, float[] p3, float[] normal)Calculate a normal vector of a plane.static doubleNormalize(double[] v)Normalise a vector v in place.static floatNormalize(float[] v)Normalise a vector 'v' in place.static doubleNormCross(double[] v1, double[] v2, double[] out)Calculate the Normalized Cross Product of two vectorsstatic floatNormCross(float[] v1, float[] v2, float[] out)Calculate the Normalized Cross Product of two vectorsstatic doubleNormQuantile(double p)Computes quantiles for standard normal distribution N(0, 1) at probability p ALGORITHM AS241 APPL.static doublePeakToPeak(double[] data)static doublePeakToPeak(double[] data, int length)static floatPeakToPeak(float[] data)static floatPeakToPeak(float[] data, int length)static intPeakToPeak(int[] data)static intPeakToPeak(int[] data, int length)static longPeakToPeak(long[] data)static longPeakToPeak(long[] data, int length)static shortPeakToPeak(short[] data)static shortPeakToPeak(short[] data, int length)static booleanPermute(int n, int[] a)Simple recursive algorithm to find the permutations of n natural numbers, not necessarily all distinct adapted from CERNLIB routine PERMU.static doublePoisson(double x, double par)compute the Poisson distribution function for (x,par) The Poisson PDF is implemented by means of Euler's Gamma-function (for the factorial), so for all integer arguments it is correct.static doublePoissonI(double x, double par)compute the Poisson distribution function for (x,par) This is a non-smooth functionstatic doubleProb(double chi2, int ndf)Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf).static doubleRMS(double[] data)static doubleRMS(double[] data, int length)static floatRMS(float[] data)static floatRMS(float[] data, int length)static intRMS(int[] data)static intRMS(int[] data, int length)static longRMS(long[] data)static longRMS(long[] data, int length)static shortRMS(short[] data)static shortRMS(short[] data, int length)booleanRootsCubic(double[] coef, double[] roots)static doubleSinc(double x, boolean norm)Calculate the sinc = sin(x)/x function if norm ==true then sinc = sinc(pi*x)/(pi*x) is usedstatic double[]Sort(double[] a, int length, boolean down)Sorts the input a arraystatic float[]Sort(float[] a, int length, boolean down)Sorts the input a arraystatic int[]Sort(int[] a, int length, boolean down)Sorts the input a arraystatic long[]Sort(long[] a, int length, boolean down)Sorts the input a arraystatic short[]Sort(short[] a, int length, boolean down)Sorts the input a arraystatic doubleStruveH0(double x)static doubleStruveH1(double x)static doubleStruveL0(double x)static doubleStruveL1(double x)static doubleStudent(double T, double ndf)Computes density function for Student's t- distribution (the probability function (integral of density) is computed in StudentI).static doubleStudentI(double T, double ndf)Calculates the cumulative distribution function of Student's t-distribution second parameter stands for number of degrees of freedom, not for the number of samples if x has Student's t-distribution, the function returns the probability of x being less than T.static doubleStudentQuantile(double p, double ndf, boolean lower_tail)static double[]Sum(double[] a, double[] b)static double[]Sum(double[] a, double[] b, int length)computes the sum of vectorsstatic float[]Sum(float[] a, float[] b)static float[]Sum(float[] a, float[] b, int length)computes the sum of vectorsstatic int[]Sum(int[] a, int[] b)static int[]Sum(int[] a, int[] b, int length)computes the sum of vectorsstatic long[]Sum(long[] a, long[] b)static long[]Sum(long[] a, long[] b, int length)computes the sum of vectorsstatic short[]Sum(short[] a, short[] b)static short[]Sum(short[] a, short[] b, int length)computes the sum of vectorsstatic doubleVariance(double[] aa, double[] ww)static doubleVavilov(double x, double kappa, double beta2)protected static doubleVavilovDenEval(double rlam, double[] AC, double[] HC, int itype)Internal function, called by Vavilov and VavilovSetstatic doubleVavilovI(double x, double kappa, double beta2)static voidVavilovSet(double rkappa, double beta2, boolean mode, double[] WCM, double[] AC, double[] HC, int[] itype, int[] npt)Internal function, called by Vavilov and VavilovIdoubleVoigt(double xx, double sigma, double lg, int r)-
Methods inherited from class de.gsi.math.TMathConstants
Abs, Abs, Abs, Abs, Abs, ACos, ASin, ATan, ATan2, C, Ccgs, Ceil, CeilNint, Cos, CosH, CUncertainty, DegToRad, E, EulerGamma, Even, Exp, Finite, Floor, FloorNint, G, Gcgs, GhbarC, GhbarCUncertainty, Gn, GnUncertainty, GUncertainty, H, Hbar, Hbarcgs, HbarUncertainty, HC, HCcgs, Hcgs, HUncertainty, Hypot, Hypot, InvPi, IsNaN, K, Kcgs, KUncertainty, Ldexp, Ln10, Log, Log10, Log2, Log2, LogE, Max, Max, Max, Max, Max, Min, Min, Min, Min, Min, MWair, Na, NaUncertainty, NextPrime, Nint, Nint, Odd, Pi, PiOver2, PiOver4, Power, Qe, QeUncertainty, R, RadToDeg, Range, Range, Range, Range, Rgair, RUncertainty, Sigma, SigmaUncertainty, Sign, Sign, Sign, Sign, Sign, Sin, SinH, Sqr, Sqrt, Sqrt2, Tan, TanH, TwoPi
-
-
-
-
Method Detail
-
KolmogorovProb
public double KolmogorovProb(double z)
Calculates the Kolmogorov distribution function, which gives the probability that Kolmogorov's test statistic will exceed the value z assuming the null hypothesis. This gives a very powerful test for comparing two one-dimensional distributions. see, for example, Eadie et al, "statistocal Methods in Experimental Physics', pp 269-270). This function returns the confidence level for the null hypothesis, where: z = dn*sqrt(n), and dn is the maximum deviation between a hypothetical distribution function and an experimental distribution with n events NOTE: To compare two experimental distributions with m and n events, use z = sqrt(m*n/(m+n))*dn Accuracy: The function is far too accurate for any imaginable application. Probabilities less than 10^-15 are returned as zero. However, remember that the formula is only valid for "large" n. Theta function inversion formula is used forz <= 1This function was translated by Rene Brun from PROBKL in CERNLIB.- Parameters:
z- input value- Returns:
- the computed result
-
KolmogorovTest
public double KolmogorovTest(int na, double[] a, int nb, double[] b, java.lang.String option)
-
RootsCubic
public boolean RootsCubic(double[] coef, double[] roots)
-
Voigt
public double Voigt(double xx, double sigma, double lg, int r)
-
BesselI
public static double BesselI(int n, double x)
-
BesselI0
public static double BesselI0(double x)
-
BesselI1
public static double BesselI1(double x)
-
BesselJ0
public static double BesselJ0(double x)
-
BesselJ1
public static double BesselJ1(double x)
-
BesselK
public static double BesselK(int n, double x)
-
BesselK0
public static double BesselK0(double x)
-
BesselK1
public static double BesselK1(double x)
-
BesselY0
public static double BesselY0(double x)
-
BesselY1
public static double BesselY1(double x)
-
Beta
public static double Beta(double p, double q)
-
BetaCf
public static double BetaCf(double x, double a, double b)
-
BetaDist
public static double BetaDist(double x, double p, double q)Computes the probability density function of the Beta distribution (the distribution function is computed in BetaDistI). The first argument is the point, where the function will be computed, second and third are the function parameters. Since the Beta distribution is bounded on both sides, it's often used to represent processes with natural lower and upper limits.- Parameters:
x- input valuep- p parameter of beta functionq- q parameter of beta function- Returns:
- probability density function of the Beta distribution
-
BetaDistI
public static double BetaDistI(double x, double p, double q)
-
BetaIncomplete
public static double BetaIncomplete(double x, double a, double b)
-
BinarySearch
public static long BinarySearch(double[] array, int length, double value)Binary search in an array of n values to locate value. Array is supposed to be sorted prior to this call. If match is found, function returns position of element. If no match found, function gives nearest element smaller than value.- Parameters:
array- input vectorlength- <= data.length elements to be usedvalue- to be searched- Returns:
- index of found value, -1 otherwise
-
BinarySearch
public static long BinarySearch(float[] array, int length, float value)Binary search in an array of n values to locate value. Array is supposed to be sorted prior to this call. If match is found, function returns position of element. If no match found, function gives nearest element smaller than value.- Parameters:
array- input vectorlength- <= data.length elements to be usedvalue- to be searched- Returns:
- index of found value, -1 otherwise
-
BinarySearch
public static long BinarySearch(int[] array, int length, int value)Binary search in an array of n values to locate value. Array is supposed to be sorted prior to this call. If match is found, function returns position of element. If no match found, function gives nearest element smaller than value.- Parameters:
array- input vectorlength- <= data.length elements to be usedvalue- to be searched- Returns:
- index of found value, -1 otherwise
-
BinarySearch
public static long BinarySearch(long[] array, int length, long value)Binary search in an array of n values to locate value. Array is supposed to be sorted prior to this call. If match is found, function returns position of element. If no match found, function gives nearest element smaller than value.- Parameters:
array- input vectorlength- <= data.length elements to be usedvalue- to be searched- Returns:
- index of found value, -1 otherwise
-
BinarySearch
public static long BinarySearch(short[] array, int length, short value)Binary search in an array of n values to locate value. Array is supposed to be sorted prior to this call. If match is found, function returns position of element. If no match found, function gives nearest element smaller than value.- Parameters:
array- input vectorlength- <= data.length elements to be usedvalue- to be searched- Returns:
- index of found value, -1 otherwise
-
Binomial
public static double Binomial(int n, int k)
-
BinomialI
public static double BinomialI(double p, int n, int k)
-
BreitWigner
public static double BreitWigner(double x, double mean, double gamma)Calculate a Breit Wigner function with mean and gamma.- Parameters:
x- input parametermean- centre of distributiongamma- width of distribution- Returns:
- the computed result
-
CauchyDist
public static double CauchyDist(double x, double t, double s)Computes the density of Cauchy distribution at point x The Cauchy distribution, also called Lorentzian distribution, is a continuous distribution describing resonance behavior The mean and standard deviation of the Cauchy distribution are undefined. The practical meaning of this is that collecting 1,000 data points gives no more accurate an estimate of the mean and standard deviation than does a single point. The formula was taken from "Engineering Statistics Handbook" on site http://www.itl.nist.gov/div898/handbook/eda/section3/eda3663.htm Implementation by Anna Kreshuk.- Parameters:
x- input valuet- the location parameters- the scale parameter- Returns:
- Cauchy distribution at point x
-
ChisquareQuantile
public static double ChisquareQuantile(double p, double ndf)Evaluate the quantiles of the chi-squared probability distribution function. Algorithm AS 91 Appl. Statist. (1975) Vol.24, P.35 implemented by Anna Kreshuk. Incorporates the suggested changes in AS R85 (vol.40(1), pp.233-5, 1991)- Parameters:
p- the probability value, at which the quantile is computedndf- number of degrees of freedom- Returns:
- quantiles of the chi-squared probability distribution
-
CorrelationCoefficient
public static double CorrelationCoefficient(double[] x, double[] y, double[] w)Calculate weighted correlation coefficient x y data and weights w as double- Parameters:
x- input vector 1y- input vector 2w- wheights weight vector- Returns:
- weighted correlation coefficient
-
Covariance
public static double Covariance(double[] xx, double[] yy, double[] ww)calculated weighted covariance xx and yy with weights ww- Parameters:
xx- input vector 1yy- input vector 2ww- weights- Returns:
- weighted covariance
-
Cross
public static double[] Cross(double[] v1, double[] v2, double[] out)Calculate the Cross Product of two vectors:- Parameters:
v1- input vector1v2- input vector2out- output vector- Returns:
- out = [v1 x v2]
-
Cross
public static float[] Cross(float[] v1, float[] v2, float[] out)Calculate the Cross Product of two vectors:- Parameters:
v1- input vector1v2- input vector2out- output vector- Returns:
- out = [v1 x v2]
-
Difference
public static double[] Difference(double[] a, double[] b)
-
Difference
public static double[] Difference(double[] a, double[] b, int length)computes the difference between vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] - b[]
-
Difference
public static float[] Difference(float[] a, float[] b)
-
Difference
public static float[] Difference(float[] a, float[] b, int length)computes the difference between vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] - b[]
-
Difference
public static int[] Difference(int[] a, int[] b)
-
Difference
public static int[] Difference(int[] a, int[] b, int length)computes the difference between vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] - b[]
-
Difference
public static long[] Difference(long[] a, long[] b)
-
Difference
public static long[] Difference(long[] a, long[] b, int length)computes the difference between vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] - b[]
-
Difference
public static short[] Difference(short[] a, short[] b)
-
Difference
public static short[] Difference(short[] a, short[] b, int length)computes the difference between vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] - b[]
-
DiLog
public static double DiLog(double x)
The DiLogarithm function Code translated by from CERNLIB DILOG function C332- Parameters:
x- input- Returns:
- the computed result
-
effectiveSampleNumber
public static double effectiveSampleNumber(double[] ww)
-
Erf
public static double Erf(double x)
Computation of the error function erf(x). Erf(x) = (2/sqrt(pi)) Integral(exp(-t^2))dt between 0 and x --- NvE 14-nov-1998 UU-SAP Utrecht- Parameters:
x- input- Returns:
- the computed result
-
Erfc
public static double Erfc(double x)
Compute the complementary error function erfc(x). Erfc(x) = (2/sqrt(pi)) Integral(exp(-t^2))dt between x and infinity Nve 14-nov-1998 UU-SAP Utrecht- Parameters:
x- input parameter- Returns:
- the computed result
-
ErfInverse
public static double ErfInverse(double x)
returns the inverse error function- Parameters:
x- must be <-1<x<1- Returns:
- the computed result
-
Factorial
public static double Factorial(int n)
Compute factorial(n).- Parameters:
n- input parameter- Returns:
- the computed result
-
FDist
public static double FDist(double F, double N, double M)
-
FDistI
public static double FDistI(double F, double N, double M)
-
Freq
public static double Freq(double x)
Computation of the normal frequency function freq(x). Freq(x) = (1/sqrt(2pi)) Integral(exp(-t^2/2))dt between -infinity and x. Translated from CERNLIB C300 by Rene Brun.- Parameters:
x- input parameter- Returns:
- the computed result
-
GamCf
public static double GamCf(double a, double x)Computation of the incomplete gamma function P(a,x) via its continued fraction representation. --- Nve 14-nov-1998 UU-SAP Utrecht- Parameters:
a- input parameterx- input parameter- Returns:
- the computed result
-
Gamma
public static double Gamma(double z)
Computation of gamma(z) for all z>0. C.Lanczos, SIAM Journal of Numerical Analysis B1 (1964), 86. --- Nve 14-nov-1998 UU-SAP Utrecht- Parameters:
z- input parameter- Returns:
- gamma(z)
-
Gamma
public static double Gamma(double a, double x)Computation of the normalized lower incomplete gamma function P(a,x) as defined in the Handbook of Mathematical Functions by Abramowitz and Stegun, formula 6.5.1 on page 260 . Its normalization is such that Gamma(a,+infinity) = 1 . Begin_Latex P(a, x) = #frac{1}{#Gamma(a) } #int_{0}^{x} t^{a-1} e^{-t} dt End_Latex --- Nve 14-nov-1998 UU-SAP Utrecht- Parameters:
a- input parameterx- input parameter- Returns:
- the computed result
-
GammaDist
public static double GammaDist(double x, double gamma, double mu, double beta)
-
GamSer
public static double GamSer(double a, double x)Computation of the incomplete gamma function P(a,x) via its series representation. --- Nve 14-nov-1998 UU-SAP Utrecht- Parameters:
a- input parameterx- input parameter- Returns:
- the computed result
-
Gauss
public static double Gauss(double x, double mean, double sigma, boolean norm)Calculate a Gaussian function with mean and sigma. If norm=true (default is false) the result is divided by sqrt(2*Pi)*sigma.- Parameters:
x- input parametermean- centre of distributionsigma- width of distributionnorm- normalisation factor- Returns:
- the computed result
-
GeometricMean
public static double GeometricMean(double[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- geometric mean of an array a with length n.
-
GeometricMean
public static double GeometricMean(double[] data)
-
GeometricMean
public static float GeometricMean(float[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- geometric mean of an array a with length n.
-
GeometricMean
public static float GeometricMean(float[] data)
-
GeometricMean
public static int GeometricMean(int[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- geometric mean of an array a with length n.
-
GeometricMean
public static int GeometricMean(int[] data)
-
GeometricMean
public static long GeometricMean(long[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- geometric mean of an array a with length n.
-
GeometricMean
public static long GeometricMean(long[] data)
-
GeometricMean
public static short GeometricMean(short[] a, int length)geometric_mean = (\Prod_{i=0}^{n-1} \abs{a[i]})^{1/n}- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- geometric mean of an array a with length n.
-
GeometricMean
public static short GeometricMean(short[] data)
-
IsInside
public static boolean IsInside(double xp, double yp, int np, double[] x, double[] y)Function which returns true if point xp,yp lies inside the polygon defined by the np points in arrays x and y, false otherwise NOTE that the polygon must be a closed polygon (1st and last point must be identical).- Parameters:
xp- test point coordinate xyp- test point coordinate ynp- number of polygon edgesx- x coordinates of polygony- y coordinates of polygon- Returns:
- true if point xp,yp lies inside
-
IsInside
public static boolean IsInside(float xp, float yp, int np, float[] x, float[] y)Function which returns true if point xp,yp lies inside the polygon defined by the np points in arrays x and y, false otherwise NOTE that the polygon must be a closed polygon (1st and last point must be identical).- Parameters:
xp- test point coordinate xyp- test point coordinate ynp- number of polygon edgesx- x coordinates of polygony- y coordinates of polygon- Returns:
- true if point xp, yp lies inside the polygon defined
-
IsInside
public static boolean IsInside(int xp, int yp, int np, int[] x, int[] y)Function which returns true if point xp,yp lies inside the polygon defined by the np points in arrays x and y, false otherwise NOTE that the polygon must be a closed polygon (1st and last point must be identical).- Parameters:
xp- test point coordinate xyp- test point coordinate ynp- number of polygon edgesx- x coordinates of polygony- y coordinates of polygon- Returns:
- true if point xp, yp lies inside the polygon defined
-
Landau
public static double Landau(double x, double mpv, double sigma, boolean norm)The LANDAU function with mpv(most probable value) and sigma. This function has been adapted from the CERNLIB routine G110 denlan. If norm=true (default is false) the result is divided by sigma- Parameters:
x- input variablempv- most probable valuesigma- width of distributionnorm- normalisation of distribution- Returns:
- the computed result
-
LandauI
public static double LandauI(double x)
-
LaplaceDist
public static double LaplaceDist(double x, double alpha, double beta)
-
LaplaceDistI
public static double LaplaceDistI(double x, double alpha, double beta)
-
LnGamma
public static double LnGamma(double z)
Computation of ln[gamma(z)] for all z>0. C.Lanczos, SIAM Journal of Numerical Analysis B1 (1964), 86 The accuracy of the result is better than 2e-10. --- Nve 14-nov-1998 UU-SAP Utrecht- Parameters:
z- input paramater- Returns:
- ln[gamma(z)]
-
LocationMaximum
public static long LocationMaximum(double[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMaximum
public static long LocationMaximum(float[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMaximum
public static long LocationMaximum(int[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMaximum
public static long LocationMaximum(long[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMinimum
public static long LocationMinimum(double[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMinimum
public static long LocationMinimum(float[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMinimum
public static long LocationMinimum(int[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMinimum
public static long LocationMinimum(long[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LocationMinimum
public static long LocationMinimum(short[] a, int length)- Parameters:
a- input vectorlength- <= data.length elements to be used- Returns:
- index of array with the minimum element. If more than one element is minimum returns first found.
-
LogNormal
public static double LogNormal(double x, double sigma, double theta, double m)Computes the density of LogNormal distribution at point x. Variable X has lognormal distribution if Y=Ln(X) has normal distribution. The formula was taken from "Engineering Statistics Handbook" on site http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm Implementation by Anna Kreshuk.- Parameters:
x- input valuesigma- the shape parametertheta- the location parameterm- the scale parameter- Returns:
- density of LogNormal distribution at point x
-
main
public static void main(java.lang.String[] argv)
-
Maximum
public static double Maximum(double[] data)
-
Maximum
public static double Maximum(double[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of largest vector element
-
Maximum
public static float Maximum(float[] data)
-
Maximum
public static float Maximum(float[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of largest vector element
-
Maximum
public static int Maximum(int[] data)
-
Maximum
public static int Maximum(int[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of largest vector element
-
Maximum
public static long Maximum(long[] data)
-
Maximum
public static long Maximum(long[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of largest vector element
-
Maximum
public static short Maximum(short[] data)
-
Maximum
public static short Maximum(short[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of largest vector element
-
Mean
public static double Mean(double[] data)
-
Mean
public static double Mean(double[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- average of vector elements
-
Mean
public static float Mean(float[] data)
-
Mean
public static float Mean(float[] data, int length)- Parameters:
data- the input vectorlength- of the input vector- Returns:
- average of vector elements
-
Mean
public static int Mean(int[] data)
-
Mean
public static int Mean(int[] data, int length)- Parameters:
data- the input vectorlength- of the input vector- Returns:
- average of vector elements
-
Mean
public static long Mean(long[] data)
-
Mean
public static long Mean(long[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- average of vector elements
-
Mean
public static short Mean(short[] data)
-
Mean
public static short Mean(short[] data, int length)- Parameters:
data- the input vectorlength- of the input vector- Returns:
- average of vector elements
-
Median
public static double Median(double[] data)
-
Median
public static double Median(double[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- median value of vector element
-
Median
public static float Median(float[] data)
-
Median
public static float Median(float[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- median value of vector element
-
Median
public static int Median(int[] data)
-
Median
public static int Median(int[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- median value of vector element
-
Median
public static long Median(long[] data)
-
Median
public static long Median(long[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- median value of vector element
-
Median
public static short Median(short[] data)
-
Median
public static short Median(short[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- median value of vector element
-
Minimum
public static double Minimum(double[] data)
-
Minimum
public static double Minimum(double[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of smallest vector element
-
Minimum
public static float Minimum(float[] data)
-
Minimum
public static float Minimum(float[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of smallest vector element
-
Minimum
public static int Minimum(int[] data)
-
Minimum
public static int Minimum(int[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of smallest vector element
-
Minimum
public static long Minimum(long[] data)
-
Minimum
public static long Minimum(long[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of smallest vector element
-
Minimum
public static short Minimum(short[] data)
-
Minimum
public static short Minimum(short[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- value of smallest vector element
-
Normal2Plane
public static double[] Normal2Plane(double[] p1, double[] p2, double[] p3, double[] normal)Calculate a normal vector of a plane.- Parameters:
p1- first 3D points belonged the plane to define it.p2- second 3D points belonged the plane to define it.p3- third 3D points belonged the plane to define it.normal- Pointer to 3D normal vector (normalised)- Returns:
- the computed result
-
Normal2Plane
public static float[] Normal2Plane(float[] p1, float[] p2, float[] p3, float[] normal)Calculate a normal vector of a plane.- Parameters:
p1- first 3D points belonged the plane to define it.p2- second 3D points belonged the plane to define it.p3- third 3D points belonged the plane to define it.normal- Pointer to 3D normal vector (normalised)- Returns:
- the computed result
-
Normalize
public static double Normalize(double[] v)
Normalise a vector v in place. Returns the norm of the original vector. This implementation (thanks Kevin Lynch <krlynch@bu.edu>) is protected against possible overflows. Find the largest element, and divide that one out.- Parameters:
v- input parameter vector- Returns:
- the computed result
-
Normalize
public static float Normalize(float[] v)
Normalise a vector 'v' in place.- Parameters:
v- input parameter vector- Returns:
- the computed result the norm of the original vector.
-
NormCross
public static double NormCross(double[] v1, double[] v2, double[] out)Calculate the Normalized Cross Product of two vectors- Parameters:
v1- input vector1v2- input vector2out- output vector- Returns:
- the computed result
-
NormCross
public static float NormCross(float[] v1, float[] v2, float[] out)Calculate the Normalized Cross Product of two vectors- Parameters:
v1- input vector1v2- input vector2out- output vector- Returns:
- the computed result
-
NormQuantile
public static double NormQuantile(double p)
Computes quantiles for standard normal distribution N(0, 1) at probability p ALGORITHM AS241 APPL. STATIST. (1988) VOL. 37, NO. 3, 477-484.- Parameters:
p- input value- Returns:
- quantiles for standard normal distribution N(0, 1) at probability p
-
PeakToPeak
public static double PeakToPeak(double[] data)
-
PeakToPeak
public static double PeakToPeak(double[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- peak-to-peak value of vector element
-
PeakToPeak
public static float PeakToPeak(float[] data)
-
PeakToPeak
public static float PeakToPeak(float[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- peak-to-peak value of vector element
-
PeakToPeak
public static int PeakToPeak(int[] data)
-
PeakToPeak
public static int PeakToPeak(int[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- peak-to-peak value of vector element
-
PeakToPeak
public static long PeakToPeak(long[] data)
-
PeakToPeak
public static long PeakToPeak(long[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- peak-to-peak value of vector element
-
PeakToPeak
public static short PeakToPeak(short[] data)
-
PeakToPeak
public static short PeakToPeak(short[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- peak-to-peak value of vector element
-
Permute
public static boolean Permute(int n, int[] a)Simple recursive algorithm to find the permutations of n natural numbers, not necessarily all distinct adapted from CERNLIB routine PERMU. The input array has to be initialised with a non descending sequence. The method returns false when all combinations are exhausted.- Parameters:
n- size of input vectora- input vector- Returns:
- false when all combinations are exhausted
-
Poisson
public static double Poisson(double x, double par)compute the Poisson distribution function for (x,par) The Poisson PDF is implemented by means of Euler's Gamma-function (for the factorial), so for all integer arguments it is correct. BUT for non-integer values it IS NOT equal to the Poisson distribution. see PoissonI to get a non-smooth function. Note that for large values of par, it is better to call Gaus(x,par,sqrt(par),true) Begin_Html- Parameters:
x- input valuepar- input parameter- Returns:
- the computed result
-
PoissonI
public static double PoissonI(double x, double par)compute the Poisson distribution function for (x,par) This is a non-smooth function- Parameters:
x- input valuepar- input parameter- Returns:
- the computed result
-
Prob
public static double Prob(double chi2, int ndf)Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf). Calculations are based on the incomplete gamma function P(a,x), where a=ndf/2 and x=chi2/2. P(a,x) represents the probability that the observed Chi-squared for a correct model should be less than the value chi2. The returned probability corresponds to 1-P(a,x), which denotes the probability that an observed Chi-squared exceeds the value chi2 by chance, even for a correct model. --- NvE 14-nov-1998 UU-SAP Utrecht- Parameters:
chi2- inputndf- number of degrees of freedom- Returns:
- the computed result
-
RMS
public static double RMS(double[] data)
-
RMS
public static double RMS(double[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- un-biased r.m.s. of vector elements
-
RMS
public static float RMS(float[] data)
-
RMS
public static float RMS(float[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- un-biased r.m.s. of vector elements
-
RMS
public static int RMS(int[] data)
-
RMS
public static int RMS(int[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- un-biased r.m.s. of vector elements
-
RMS
public static long RMS(long[] data)
-
RMS
public static long RMS(long[] data, int length)- Parameters:
data- the input vectorlength- <= d data.length elements to be used- Returns:
- un-biased r.m.s. of vector elements
-
RMS
public static short RMS(short[] data)
-
RMS
public static short RMS(short[] data, int length)- Parameters:
data- the input vectorlength- <= data.length elements to be used- Returns:
- un-biased r.m.s. of vector elements
-
Sinc
public static double Sinc(double x, boolean norm)Calculate the sinc = sin(x)/x function if norm ==true then sinc = sinc(pi*x)/(pi*x) is used- Parameters:
x- input parameternorm- normalisation factor- Returns:
- the computed result
-
Sort
public static double[] Sort(double[] a, int length, boolean down)Sorts the input a array- Parameters:
a- the input arraylength- <= data.length elements to be useddown- true: ascending , false: descending order- Returns:
- the sorted array
-
Sort
public static float[] Sort(float[] a, int length, boolean down)Sorts the input a array- Parameters:
a- the input arraylength- <= data.length elements to be useddown- true: ascending , false: descending order- Returns:
- the sorted array
-
Sort
public static int[] Sort(int[] a, int length, boolean down)Sorts the input a array- Parameters:
a- the input arraylength- <= data.length elements to be useddown- true: ascending , false: descending order- Returns:
- the sorted array
-
Sort
public static long[] Sort(long[] a, int length, boolean down)Sorts the input a array- Parameters:
a- the input arraylength- <= data.length elements to be useddown- true: ascending , false: descending order- Returns:
- the sorted array
-
Sort
public static short[] Sort(short[] a, int length, boolean down)Sorts the input a array- Parameters:
a- the input arraylength- <= data.length elements to be useddown- true: ascending , false: descending order- Returns:
- the sorted array
-
StruveH0
public static double StruveH0(double x)
-
StruveH1
public static double StruveH1(double x)
-
StruveL0
public static double StruveL0(double x)
-
StruveL1
public static double StruveL1(double x)
-
Student
public static double Student(double T, double ndf)Computes density function for Student's t- distribution (the probability function (integral of density) is computed in StudentI). First parameter stands for x - the actual variable of the density function p(x) and the point at which the density is calculated. Second parameter stands for number of degrees of freedom. About Student distribution: Student's t-distribution is used for many significance tests, for example, for the Student's t-tests for the statistical significance of difference between two sample means and for confidence intervals for the difference between two population means. Example: suppose we have a random sample of size n drawn from normal distribution with mean Mu and st.deviation Sigma. Then the variable t = (sample_mean - Mu)/(sample_deviation / sqrt(n)) has Student's t-distribution with n-1 degrees of freedom. NOTE that this function's second argument is number of degrees of freedom, not the sample size. As the number of degrees of freedom grows, t-distribution approaches Normal(0,1) distribution. Implementation by Anna Kreshuk.- Parameters:
T- input valuendf- number of degrees of freedom- Returns:
- value of the density function for Student's t- distribution
-
StudentI
public static double StudentI(double T, double ndf)Calculates the cumulative distribution function of Student's t-distribution second parameter stands for number of degrees of freedom, not for the number of samples if x has Student's t-distribution, the function returns the probability of x being less than T. Implementation by Anna Kreshuk.- Parameters:
T- input valuendf- number of degrees of freedom- Returns:
- cumulative distribution function of Student's t-distribution
-
StudentQuantile
public static double StudentQuantile(double p, double ndf, boolean lower_tail)
-
Sum
public static double[] Sum(double[] a, double[] b)
-
Sum
public static double[] Sum(double[] a, double[] b, int length)computes the sum of vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] =[] a + b[]
-
Sum
public static float[] Sum(float[] a, float[] b)
-
Sum
public static float[] Sum(float[] a, float[] b, int length)computes the sum of vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] + b[]
-
Sum
public static int[] Sum(int[] a, int[] b)
-
Sum
public static int[] Sum(int[] a, int[] b, int length)computes the sum of vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] + b[]
-
Sum
public static long[] Sum(long[] a, long[] b)
-
Sum
public static long[] Sum(long[] a, long[] b, int length)computes the sum of vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] + b[]
-
Sum
public static short[] Sum(short[] a, short[] b)
-
Sum
public static short[] Sum(short[] a, short[] b, int length)computes the sum of vectors- Parameters:
a- input vector ab- input vector blength- minimum length to be taken into account- Returns:
- ret[] = a[] + b[]
-
Variance
public static double Variance(double[] aa, double[] ww)
-
Vavilov
public static double Vavilov(double x, double kappa, double beta2)
-
VavilovDenEval
protected static double VavilovDenEval(double rlam, double[] AC, double[] HC, int itype)Internal function, called by Vavilov and VavilovSet- Parameters:
rlam- ???AC- ???HC- ???itype- ???- Returns:
- internal value
-
VavilovI
public static double VavilovI(double x, double kappa, double beta2)
-
VavilovSet
public static void VavilovSet(double rkappa, double beta2, boolean mode, double[] WCM, double[] AC, double[] HC, int[] itype, int[] npt)Internal function, called by Vavilov and VavilovI- Parameters:
rkappa- ???beta2- ???mode- ???WCM- ???AC- ???HC- ???itype- ???npt- ???
-
-