SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
LognormalDistFromMoments.java
1/*
2 * Class: LognormalDistFromMoments
3 * Description: lognormal 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
42public class LognormalDistFromMoments extends LognormalDist {
43 public LognormalDistFromMoments(double mean, double var) {
44 super(getMu(mean, var), Math.sqrt(getSigma2(mean, var)));
45 }
46
47 private static double getMu(double mean, double var) {
48 final double sigma2 = getSigma2(mean, var);
49 return Math.log(mean) - sigma2 / 2.0;
50 }
51
52 private static double getSigma2(double mean, double var) {
53 if (mean <= 0)
54 throw new IllegalArgumentException("Mean must be positive");
55 if (var <= 0)
56 throw new IllegalArgumentException("Variance must be positive");
57 return Math.log(var / (mean * mean) + 1);
58 }
59}
double getMu()
Returns the parameter of this object.
LognormalDist()
Constructs a LognormalDist object with default parameters and .