25package umontreal.ssj.probdist;
57 public double prob(
int x) {
61 public double cdf(
int x) {
65 public double barF(
int x) {
89 public static double prob(
int i,
int j,
int x) {
91 throw new IllegalArgumentException(
"j < i");
95 return (1.0 / (j - i + 1.0));
102 public static double cdf(
int i,
int j,
int x) {
104 throw new IllegalArgumentException(
"j < i");
110 return ((x - i + 1) / (j - i + 1.0));
119 public static double barF(
int i,
int j,
int x) {
121 throw new IllegalArgumentException(
"j < i");
127 return ((j - x + 1.0) / (j - i + 1.0));
134 public static int inverseF(
int i,
int j,
double u) {
136 throw new IllegalArgumentException(
"j < i");
138 if (u > 1.0 || u < 0.0)
139 throw new IllegalArgumentException(
"u not in [0, 1]");
146 return i + (int) (u * (j - i + 1.0));
165 public static double[]
getMLE(
int[] x,
int n) {
167 throw new IllegalArgumentException(
"n <= 0");
169 double parameters[] =
new double[2];
170 parameters[0] = (double) Integer.MAX_VALUE;
171 parameters[1] = (double) Integer.MIN_VALUE;
172 for (
int i = 0; i < n; i++) {
173 if ((
double) x[i] < parameters[0])
174 parameters[0] = (double) x[i];
175 if ((
double) x[i] > parameters[1])
176 parameters[1] = (double) x[i];
192 double parameters[] =
getMLE(x, n);
194 return new UniformIntDist((
int) parameters[0], (
int) parameters[1]);
205 throw new IllegalArgumentException(
"j < i");
207 return ((i + j) / 2.0);
218 throw new IllegalArgumentException(
"j < i");
220 return (((j - i + 1.0) * (j - i + 1.0) - 1.0) / 12.0);
252 throw new IllegalArgumentException(
"j < i");
254 supportA = this.i = i;
255 supportB = this.j = j;
263 double[] retour = { i, j };
271 return getClass().getSimpleName() +
" : i = " + i +
", j = " + j;
Classes implementing discrete distributions over the integers should inherit from this class.