I'm trying to implement logNormal distribution into my java program because lognormal dist doesn't exist into apache commons math library.
I have no problem to re-write density and cumulative probability function, extending abstract classes of apache commons math library, like this :
public double cumulativeProbability(double mu, double sigma, double x) {
if (sigma <= 0.0) {
throw new IllegalArgumentException("sigma <= 0");
}
if (x <= 0.0) {
return 0.0;
}
return this.cumulativeProbability((Math.log(x) - mu) / sigma);
}
public double cumulativeProbability(double x){
double var = 0.0;
NormalDistributionImpl normalDist = new NormalDistributionImpl();
try {
var = normalDist.cumulativeProbability(x);
} catch (MathException e) {}
return var;
}
public double density (double x) {
return density (mu, sigma, x);
}
public static double density (double mu, double sigma, double x) {
if (sigma <= 0)
throw new IllegalArgumentException ("sigma <= 0");
if (x <= 0)
return 0;
double diff = Math.log (x) - mu;
return Math.exp (-diff*diff/(2*sigma*sigma))/
(Math.sqrt (2*Math.PI)*sigma*x);
}
Apache commons math need implementation of a list of utilies function to compute the inverse cumulative probability, and i don't know which upper/lowerbound/initial domain my lognormal distribution can take ...
I suppose it's something like this, but i'm not sure : x between [0 ; +infinity] ?
Thanks a lot for your help
p = Desired probability for the critical value.
Access the domain value lower bound, based on p, used to bracket a CDF root. This method is used by inverseCumulativeProbability(double) to find critical values.
public double getDomainLowerBound(double p){
return ?;
}
Access the domain value upper bound, based on p, used to bracket a CDF root. This method is used by inverseCumulativeProbability(double) to find critical values.
public double getDomainUpperBound(double p){
return ?;
}
Access the initial domain value, based on p, used to bracket a CDF root. This method is used by inverseCumulativeProbability(double) to find critical values.
public double getInitialDomain(double p){
return ?;
}
Access the lower bound of the support. Returns: lower bound of the support (might be Double.NEGATIVE_INFINITY)
public double getSupportLowerBound(){
return ?;
}
Access the upper bound of the support. Returns: upper bound of the support (might be Double.POSITIVE_INFINITY)
public double getSupportUpperBound(){
return ?;
}
Use this method to get information about whether the lower bound of the support is inclusive or not. Returns: whether the lower bound of the support is inclusive or not
public boolean isSupportLowerBoundInclusive(){
return ;
}
Use this method to get information about whether the upper bound of the support is inclusive or not. Returns: whether the upper bound of the support is inclusive or not
public boolean isSupportUpperBoundInclusive(){
return ;
}