com.bnd.math.business.rand.NumberLogNormalDistributionProvider Maven / Gradle / Ivy
The newest version!
package com.bnd.math.business.rand;
import com.bnd.core.util.RandomUtil;
import com.bnd.math.domain.rand.ShapeLocationDistribution;
class NumberLogNormalDistributionProvider extends AbstractRandomDistributionProvider {
private final ShapeLocationDistribution distribution;
protected NumberLogNormalDistributionProvider(ShapeLocationDistribution distribution) {
super(distribution);
this.distribution = distribution;
}
@Override
public T next() {
return RandomUtil.nextLogNormal(clazz, distribution.getLocation(), distribution.getShape());
}
@Override
public Double mean() {
double location = distribution.getLocation().doubleValue();
double shape = distribution.getShape().doubleValue();
return Math.exp(location + (shape / 2));
}
@Override
public Double variance() {
double location = distribution.getLocation().doubleValue();
double shape = distribution.getShape().doubleValue();
return Math.exp(2 * (location + shape)) - Math.exp(2 * location + shape);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy