MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / setUsingData

Method setUsingData

JSAT/src/jsat/distributions/Weibull.java:147–186  ·  view source on GitHub ↗
(Vec data)

Source from the content-addressed store, hash-verified

145 }
146
147 @Override
148 public void setUsingData(Vec data)
149 {
150 /* Method of parameter esstimation is more complex than for
151 * other distirbutions, see
152 * http://www.qualitydigest.com/jan99/html/body_weibull.html
153 * for the method used. NOTE the above article has alpha and beta in oposite order
154 */
155
156 Vec sData = data.sortedCopy();
157 DenseVector ranks = new DenseVector(sData.length());
158 for(int i = 0; i < sData.length(); i++)
159 {
160 //Get the median rank
161 double tmp = (i+1.0-0.3)/(sData.length()+0.4);
162
163 tmp = 1/(1-tmp);
164
165 tmp = log(log(tmp));
166
167 ranks.set(i, tmp);
168
169 sData.set(i, log(sData.get(i)));
170 }
171
172
173 double[] s = SimpleLinearRegression.regres(sData, ranks);
174
175 //The shape parameter is approximatly the slope
176
177 setAlpha(s[1]);
178
179 /*
180 * We can now compute alpha directly.
181 * Note the page use y = m x + b, instead of y = b x + a
182 *
183 */
184
185 setBeta(exp(-s[0]/alpha));
186 }
187
188 @Override
189 public double mean()

Callers

nothing calls this directly

Calls 10

lengthMethod · 0.95
setMethod · 0.95
setMethod · 0.95
getMethod · 0.95
regresMethod · 0.95
setAlphaMethod · 0.95
setBetaMethod · 0.95
logMethod · 0.80
expMethod · 0.80
sortedCopyMethod · 0.45

Tested by

no test coverage detected