JavaDoc added
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
package net.berack.upo.valpre.rand;
|
||||
|
||||
/**
|
||||
* Represents a probability distribution.
|
||||
*/
|
||||
public interface Distribution {
|
||||
public double sample(Rng rng);
|
||||
|
||||
/**
|
||||
* Represents an exponential distribution.
|
||||
*/
|
||||
public static class Exponential implements Distribution {
|
||||
private final double lambda;
|
||||
|
||||
/**
|
||||
* Creates a new exponential distribution with the given rate.
|
||||
* @param lambda The rate of the distribution.
|
||||
*/
|
||||
public Exponential(double lambda) {
|
||||
this.lambda = lambda;
|
||||
}
|
||||
@@ -16,10 +26,18 @@ public interface Distribution {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a normal distribution.
|
||||
*/
|
||||
public static class Normal implements Distribution {
|
||||
private final double mean;
|
||||
private final double sigma;
|
||||
|
||||
/**
|
||||
* Creates a new normal distribution with the given mean and standard deviation.
|
||||
* @param mean The mean of the distribution.
|
||||
* @param sigma The standard deviation of the distribution.
|
||||
*/
|
||||
public Normal(double mean, double sigma) {
|
||||
this.mean = mean;
|
||||
this.sigma = sigma;
|
||||
@@ -32,11 +50,19 @@ public interface Distribution {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a normal distribution using the Box-Muller transform.
|
||||
*/
|
||||
public static class NormalBoxMuller implements Distribution {
|
||||
private final double mean;
|
||||
private final double sigma;
|
||||
private double next = Double.NaN;
|
||||
|
||||
/**
|
||||
* Creates a new normal distribution with the given mean and standard deviation.
|
||||
* @param mean The mean of the distribution.
|
||||
* @param sigma The standard deviation of the distribution.
|
||||
*/
|
||||
public NormalBoxMuller(double mean, double sigma) {
|
||||
this.mean = mean;
|
||||
this.sigma = sigma;
|
||||
|
||||
Reference in New Issue
Block a user