Skip to content

Commit

Permalink
Fix bug when exponentiated Weibull distribution is fitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaselsteiner committed Jan 8, 2020
1 parent 93ea3fb commit df71a5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ def test_fitting_exponentiated_weibull(self):
self.assertGreater(params[2], 2) # scale parameter should be about 3.
self.assertLess(params[2], 4)

# Check whether the fitted distribution has a working CDF and PDF.
self.assertGreater(dist.cdf(2), 0)
self.assertGreater(dist.pdf(2), 0)


if __name__ == '__main__':
unittest.main()
10 changes: 8 additions & 2 deletions viroconcom/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ def _get_parameter_values(self, rv_values, dependencies):
parameter_vals.append(defaults[i])
elif dependencies is None or dependencies[i] is None:
parameter_vals.append(param(None))
self._check_parameter_value(i, parameter_vals[-1])
if parameter_vals[-1] is not None:
self._check_parameter_value(i, parameter_vals[-1])
else:
parameter_vals.append(param(rv_values[dependencies[i]]))
try: # if list fo values iterate over values
Expand Down Expand Up @@ -596,7 +597,12 @@ def estimateAlphaBetaWithWLS(delta, xi, pi, do_return_parameters=True):
raise NotImplementedError(err_msg)

params = (pHat[1], loc, pHat[0], shape2) # shape, location, scale, shape2
self.__init__(*params)
constantParams = (ConstantParam(pHat[1]), # shape parameter.
ConstantParam(loc), # location parameter.
ConstantParam(pHat[0]), # scale parameter.
ConstantParam(shape2)) # Second shape parameter

self.__init__(*constantParams)

return params

Expand Down
2 changes: 1 addition & 1 deletion viroconcom/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.5'
__version__ = '1.2.6'

0 comments on commit df71a5b

Please sign in to comment.