apache-commons-math

How to calculate the inverse cumulative beta distribution function in java

六月ゝ 毕业季﹏ 提交于 2019-12-06 02:09:41
问题 I am looking for a java library / implementation which supports the calculation of the inverse cumulative distribution function for the beta distribution (aka estimation of quantiles) with reasonable precision . Of course I have tried apache commons math, but in version 3 there still seem to be some issues with the precision. Below the problem which lead to this question is described extensively. Suppose I want to calculate the credible interval of a beta distribution with a lot of trials. In

How to compute integration of a function in apache commons math3 library?

大兔子大兔子 提交于 2019-12-05 17:43:38
I am trying to integrate a very simple function. integral(x.dx). Instead of getting an answer of 1, I am getting an answer as 0, or 0.5 when I include limits from 0 to 1. Is there something I misunderstand about the implementation of the integration in apache commons library? import org.apache.commons.math3.analysis.integration.*; import org.apache.commons.math3.analysis.polynomials.*; public static void main(String args[]) { SimpsonIntegrator simpson = new SimpsonIntegrator(); TrapezoidIntegrator trapezoid = new TrapezoidIntegrator(); double[] vector = new double[2]; vector[0] = 0; vector[1]

Create a uniform random number based on a hash

人盡茶涼 提交于 2019-12-04 14:27:42
问题 I need a good pseudo random number based on a key consisting of a string and a long. I should get the same random number when I query using the same key and also, I should get a very different number if I query using a slightly different key, even when say the long in the key is off by 1. I tried this code and the random numbers are unique but for similar numbers they seem correlated. import java.util.Date; import java.util.Random; import org.apache.commons.lang3.builder.HashCodeBuilder;

Interpolate function using Apache Commons Math

房东的猫 提交于 2019-12-04 13:28:58
I'm trying to implement some Interpolation functions to plot some values where the X value = Date.seconds and the Y value = double. I'v been researching using the Apache Commons Math lib to achieve this and I've found a method I think I might be able to use here The method I'm trying to understand: public double linearInterp(double[] x, double[] y, double xi) { // return linear interpolation of (x,y) on xi LinearInterpolator li = new LinearInterpolator(); PolynomialSplineFunction psf = li.interpolate(x, y); double yi = psf.value(xi); return yi; } I don't understand where I'm supposed to get

Using Apache Commons Math to determine confidence intervals

戏子无情 提交于 2019-12-03 16:13:28
问题 I have a set of benchmark data for which I compute summary statistics using Apache Math Commons. Now I want to use the package to compute confidence intervals for the arithmetic means of e.g. running time measurements. Is this possible at all? I am convinced that the package supports this, however I am at a loss about where to start. This is the solution I ended up using with the help of Brent Worden's suggestion: private double getConfidenceIntervalWidth(StatisticalSummary statistics, double

Create a uniform random number based on a hash

不羁的心 提交于 2019-12-03 08:58:25
I need a good pseudo random number based on a key consisting of a string and a long. I should get the same random number when I query using the same key and also, I should get a very different number if I query using a slightly different key, even when say the long in the key is off by 1. I tried this code and the random numbers are unique but for similar numbers they seem correlated. import java.util.Date; import java.util.Random; import org.apache.commons.lang3.builder.HashCodeBuilder; public class HashKeyTest { long time; String str; public HashKeyTest(String str, long time) { this.time =

Using Apache Commons Math to determine confidence intervals

馋奶兔 提交于 2019-12-03 06:20:01
I have a set of benchmark data for which I compute summary statistics using Apache Math Commons. Now I want to use the package to compute confidence intervals for the arithmetic means of e.g. running time measurements. Is this possible at all? I am convinced that the package supports this, however I am at a loss about where to start. This is the solution I ended up using with the help of Brent Worden's suggestion: private double getConfidenceIntervalWidth(StatisticalSummary statistics, double significance) { TDistribution tDist = new TDistribution(statistics.getN() - 1); double a = tDist

Java - Computation of Derivations with Apache Commons Mathematic Library

≡放荡痞女 提交于 2019-11-30 10:33:53
I have a problem in using the apache commons math library. I just want to create functions like f(x) = 4x^2 + 2x and I want to compute the derivative of this function --> f'(x) = 8x + 2 I read the article about Differentiation ( http://commons.apache.org/proper/commons-math/userguide/analysis.html , section 4.7). There is an example which I don't understand: int params = 1; int order = 3; double xRealValue = 2.5; DerivativeStructure x = new DerivativeStructure(params, order, 0, xRealValue); DerivativeStructure y = f(x); //COMPILE ERROR System.out.println("y = " + y.getValue(); System.out

Generating random integers within range with a probability distribution

て烟熏妆下的殇ゞ 提交于 2019-11-30 09:44:19
I have a problem where I want to generate a set of random integer values between 1 and 5 inclusive using a probability distribution. Poisson and Inverse Gamma are two distributions that show the characteristics I am after (majority at mean, less higher numbers) that I have found. I am looking at using Apache Commons Math but I wasn't sure how to generate the numbers I wanted using the distributions available. From your problem description, it sounds like you actually want a sample generated from a discrete probability distribution, and you can use EnumeratedIntegerDistribution for this purpose

Java - Computation of Derivations with Apache Commons Mathematic Library

做~自己de王妃 提交于 2019-11-29 15:50:06
问题 I have a problem in using the apache commons math library. I just want to create functions like f(x) = 4x^2 + 2x and I want to compute the derivative of this function --> f'(x) = 8x + 2 I read the article about Differentiation (http://commons.apache.org/proper/commons-math/userguide/analysis.html, section 4.7). There is an example which I don't understand: int params = 1; int order = 3; double xRealValue = 2.5; DerivativeStructure x = new DerivativeStructure(params, order, 0, xRealValue);