SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ErlangDist.java
1/*
2 * Class: ErlangDist
3 * Description: Erlang distribution
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.probdist;
26
39public class ErlangDist extends GammaDist {
40
45 public ErlangDist(int k) {
46 super(k);
47 }
48
54 public ErlangDist(int k, double lambda) {
55 super(k, lambda);
56 }
57
61 public static double density(int k, double lambda, double x) {
62 return density((double) k, lambda, x);
63 }
64
68 public static double cdf(int k, double lambda, int d, double x) {
69 return cdf((double) k, d, lambda * x);
70 }
71
75 public static double barF(int k, double lambda, int d, double x) {
76 return barF((double) k, d, lambda * x);
77 }
78
82 public static double inverseF(int k, double lambda, int d, double u) {
83 return inverseF((double) k, lambda, d, u);
84 }
85
101 public static double[] getMLE(double[] x, int n) {
102 double parameters[] = GammaDist.getMLE(x, n);
103 parameters[0] = Math.round(parameters[0]);
104 return parameters;
105 }
106
115 public static ErlangDist getInstanceFromMLE(double[] x, int n) {
116 double parameters[] = getMLE(x, n);
117 return new ErlangDist((int) parameters[0], parameters[1]);
118 }
119
126 public static double getMean(int k, double lambda) {
127 if (k <= 0)
128 throw new IllegalArgumentException("k <= 0");
129 if (lambda <= 0.0)
130 throw new IllegalArgumentException("lambda <= 0");
131 return (k / lambda);
132 }
133
141 public static double getVariance(int k, double lambda) {
142 if (k <= 0)
143 throw new IllegalArgumentException("k <= 0");
144 if (lambda <= 0.0)
145 throw new IllegalArgumentException("lambda <= 0");
146
147 return (k / (lambda * lambda));
148 }
149
156 public static double getStandardDeviation(int k, double lambda) {
157 if (k <= 0)
158 throw new IllegalArgumentException("k <= 0");
159 if (lambda <= 0.0)
160 throw new IllegalArgumentException("lambda <= 0");
161
162 return (Math.sqrt(k) / lambda);
163 }
164
168 public int getK() {
169 return (int) getAlpha();
170 }
171
177 public void setParams(int k, double lambda, int d) {
178 super.setParams(k, lambda, d);
179 }
180
185 public double[] getParams() {
186 return super.getParams();
187 }
188
192 public String toString() {
193 return getClass().getSimpleName() + " : k = " + (int) super.getAlpha() + ", lambda = " + super.getLambda();
194 }
195
196}
ErlangDist(int k, double lambda)
Constructs a ErlangDist object with parameters = k and.
static double density(int k, double lambda, double x)
Computes the density function.
static double[] getMLE(double[] x, int n)
Estimates the parameters of the Erlang distribution using the maximum likelihood method,...
static ErlangDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of an Erlang distribution with parameters.
static double barF(int k, double lambda, int d, double x)
Computes the complementary distribution function.
ErlangDist(int k)
Constructs a ErlangDist object with parameters = k and .
static double inverseF(int k, double lambda, int d, double u)
Returns the inverse distribution function.
int getK()
Returns the parameter for this object.
static double getStandardDeviation(int k, double lambda)
Computes and returns the standard deviation of the Erlang distribution with parameters and .
static double getMean(int k, double lambda)
Computes and returns the mean, , of the Erlang distribution with parameters and .
String toString()
Returns a String containing information about the current distribution.
double[] getParams()
Return a table containing parameters of the current distribution.
static double cdf(int k, double lambda, int d, double x)
Computes the distribution function using the gamma distribution function.
static double getVariance(int k, double lambda)
Computes and returns the variance, , of the Erlang distribution with parameters and .
void setParams(int k, double lambda, int d)
Sets the parameters and of the distribution for this object.
GammaDist(double alpha)
Constructs a GammaDist object with parameters = alpha and .
double getAlpha()
Return the parameter for this object.