25package umontreal.ssj.probdist;
27import umontreal.ssj.util.Num;
28import umontreal.ssj.util.RootFinder;
29import umontreal.ssj.functions.MathFunction;
52 protected double mean;
54 public Function(
double mean) {
58 public double evaluate(
double x) {
59 if (x <= 0.0 || x >= 1.0)
61 return (x + mean * (1.0 - x) * Math.log1p(-x));
72 public double prob(
int x) {
75 return t * Math.pow(theta, x) / x;
78 public double cdf(
int x) {
83 for (
int i = 2; i <= x; i++) {
90 public double barF(
int x) {
97 term *= theta * (i - 1) / i;
104 return inverseF(theta, u);
123 public static double prob(
double theta,
int x) {
124 if (theta <= 0 || theta >= 1)
125 throw new IllegalArgumentException(
"theta not in range (0,1)");
128 return -1.0 / Math.log1p(-theta) * Math.pow(theta, x) / x;
134 public static double cdf(
double theta,
int x) {
135 if (theta <= 0 || theta >= 1)
136 throw new IllegalArgumentException(
"theta not in range (0,1)");
139 double res =
prob(theta, 1);
141 for (
int i = 2; i <= x; i++) {
153 public static double barF(
double theta,
int x) {
154 if (theta <= 0 || theta >= 1)
155 throw new IllegalArgumentException(
"theta not in range (0,1)");
158 double res =
prob(theta, x);
162 term *= theta * (i - 1) / i;
168 public static int inverseF(
double theta,
double u) {
169 throw new UnsupportedOperationException();
187 public static double[]
getMLE(
int[] x,
int n) {
189 throw new IllegalArgumentException(
"n <= 0");
192 parameters =
new double[1];
194 for (
int i = 0; i < n; i++) {
198 double mean = (double) sum / (
double) n;
200 Function f =
new Function(mean);
215 double parameters[] =
getMLE(x, n);
228 if (theta <= 0.0 || theta >= 1.0)
229 throw new IllegalArgumentException(
"theta not in range (0,1)");
231 return ((-1 / Math.log1p(-theta)) * (theta / (1 - theta)));
244 if (theta <= 0.0 || theta >= 1.0)
245 throw new IllegalArgumentException(
"theta not in range (0,1)");
247 double v = Math.log1p(-theta);
248 return ((-theta * (theta + v)) / ((1 - theta) * (1 - theta) * v * v));
272 if (theta <= 0 || theta >= 1)
273 throw new IllegalArgumentException(
"theta not in range (0,1)");
275 t = -1.0 / Math.log1p(-theta);
283 double[] retour = { theta };
291 return getClass().getSimpleName() +
" : theta = " + theta;
Classes implementing discrete distributions over the integers should inherit from this class.
static double EPSILON
Environment variable that determines what probability terms can be considered as negligible when buil...
double prob(int x)
Returns , the probability of .
double getMean()
Returns the mean of the distribution function.
double getVariance()
Returns the variance of the distribution function.
int inverseFInt(double u)
Returns the inverse distribution function , where.
static double[] getMLE(int[] x, int n)
Estimates the parameter of the logarithmic distribution using the maximum likelihood method,...
static double cdf(double theta, int x)
Computes the distribution function .
static LogarithmicDist getInstanceFromMLE(int[] x, int n)
Creates a new instance of a logarithmic distribution with parameter.
static double getVariance(double theta)
Computes and returns the variance.
static double prob(double theta, int x)
Computes the logarithmic probability given in ( flogar ) .
void setTheta(double theta)
Sets the associated with this object.
double getTheta()
Returns the associated with this object.
String toString()
Returns a String containing information about the current distribution.
double[] getParams()
Return a table containing the parameters of the current distribution.
double getStandardDeviation()
Returns the standard deviation of the distribution function.
static double getMean(double theta)
Computes and returns the mean.
double barF(int x)
Returns , the complementary distribution function.
LogarithmicDist(double theta)
Constructs a logarithmic distribution with parameter theta.
static double getStandardDeviation(double theta)
Computes and returns the standard deviation of the logarithmic distribution with parameter theta.
static double barF(double theta, int x)
Computes the complementary distribution function.
double cdf(int x)
Returns the distribution function evaluated at (see ( FDistDisc )).
This class provides numerical methods to solve non-linear equations.
static double brentDekker(double a, double b, MathFunction f, double tol)
Computes a root of the function in f using the Brent-Dekker method.
This interface should be implemented by classes which represent univariate mathematical functions.