@@ -88,6 +88,49 @@ public BetaScaled(double a, double b, double location, double scale, System.Rand
88
88
_scale = scale ;
89
89
}
90
90
91
+ /// <summary>
92
+ /// Create a Beta PERT distribution, used in risk analysis and other domains where an expert forecast
93
+ /// is used to construct an underlying beta distribution.
94
+ /// </summary>
95
+ /// <param name="min">The minimum value.</param>
96
+ /// <param name="max">The maximum value.</param>
97
+ /// <param name="likely">The most likely value (mode).</param>
98
+ /// <param name="randomSource">The random number generator which is used to draw random samples.</param>
99
+ /// <returns>The Beta distribution derived from the PERT parameters.</returns>
100
+ public static BetaScaled PERT ( double min , double max , double likely , System . Random randomSource = null )
101
+ {
102
+ if ( min > max || likely > max || likely < min )
103
+ {
104
+ throw new ArgumentException ( Resources . InvalidDistributionParameters ) ;
105
+ }
106
+
107
+ // specified to make the formulas match the literature;
108
+ // traditionally set to 4 so that the range between min and max
109
+ // represents six standard deviations (sometimes called
110
+ // "the six-sigma assumption").
111
+ const double lambda = 4 ;
112
+
113
+ // calculate the mean
114
+ double mean = ( min + max + lambda * likely ) / ( lambda + 2 ) ;
115
+
116
+ // derive the shape parameters a and b
117
+ double a ;
118
+
119
+ // special case where mean and mode are identical
120
+ if ( mean == likely )
121
+ {
122
+ a = ( lambda / 2 ) + 1 ;
123
+ }
124
+ else
125
+ {
126
+ a = ( ( mean - min ) * ( 2 * likely - min - max ) ) / ( ( likely - mean ) * ( max - min ) ) ;
127
+ }
128
+
129
+ double b = ( a * ( max - mean ) ) / ( mean - min ) ;
130
+
131
+ return new BetaScaled ( a , b , min , max - min , randomSource ) ;
132
+ }
133
+
91
134
/// <summary>
92
135
/// A string representation of the distribution.
93
136
/// </summary>
0 commit comments