diff --git a/pywafo/src/wafo/stats/estimation.py b/pywafo/src/wafo/stats/estimation.py index 735498c..3a67733 100644 --- a/pywafo/src/wafo/stats/estimation.py +++ b/pywafo/src/wafo/stats/estimation.py @@ -385,7 +385,7 @@ class Profile(object): mphat = self._par.copy() mphat[self.i_notfixed] = phatnotfixed logSF = self.fit_dist.dist.logsf(self.x, *mphat) - return np.where(np.isfinite(logSF), logSF, -np.inf) + return np.where(np.isfinite(logSF), logSF, np.nan) def _nlogfun(self, free_par, fix_par): diff --git a/pywafo/src/wafo/stats/tests/test_estimation.py b/pywafo/src/wafo/stats/tests/test_estimation.py new file mode 100644 index 0000000..5450cf2 --- /dev/null +++ b/pywafo/src/wafo/stats/tests/test_estimation.py @@ -0,0 +1,65 @@ +''' +Created on 19. nov. 2010 + +@author: pab +''' + +import wafo.stats as ws +from wafo.stats.estimation import Profile, FitDistribution +from numpy import log, array +def test_profile(): + ''' + # MLE + import wafo.stats as ws + R = ws.weibull_min.rvs(1,size=100) + >>> R = array([ 1.11214852, 0.55730247, 0.88241032, 0.13421021, 0.21939628, + ... 0.93901239, 4.55065051, 0.06728561, 1.65808964, 3.31725493, + ... 1.26022136, 0.48707756, 1.04600817, 3.45064509, 0.23478845, + ... 0.73197928, 0.78702608, 1.10566899, 0.08770387, 0.29773143, + ... 0.442589 , 0.06017045, 0.99086215, 0.36520787, 0.55931192, + ... 0.02220038, 0.09683231, 0.2407798 , 1.5550326 , 1.21834857, + ... 0.51317074, 3.12672982, 2.01984527, 1.42837289, 1.60665276, + ... 0.07643233, 0.97254151, 0.71870616, 0.15669964, 0.7647863 , + ... 2.15586998, 1.03167507, 0.66384501, 0.26824186, 0.25953582, + ... 0.52773641, 0.3371869 , 1.17897776, 0.36094868, 0.49593992, + ... 0.12124638, 0.13178139, 0.28325022, 1.2189952 , 2.85895075, + ... 1.94868469, 1.5216953 , 0.77066953, 0.42610845, 1.52848366, + ... 0.26570905, 0.52072509, 1.03106309, 0.34430637, 1.36386879, + ... 1.05857501, 0.66754409, 3.18836655, 0.40063524, 0.40696207, + ... 1.24167978, 0.27927484, 3.95644924, 1.34793436, 0.66225993, + ... 0.46567866, 0.09325875, 1.90895739, 1.23831713, 0.29819745, + ... 1.10528719, 0.01973962, 0.56370415, 0.66831751, 1.33781636, + ... 0.53985288, 0.85251279, 1.75369891, 0.08066507, 0.29273944, + ... 0.38886539, 0.20961546, 0.93814728, 0.08732068, 1.6336713 , + ... 1.38893923, 2.05882459, 0.51709862, 0.37553027, 0.06829269]) + + >>> phat = FitDistribution(ws.weibull_min, R, 1, scale=1, floc=0.0) + >>> phat.par + array([ 1.07424857, 0. , 0.96282996]) + + # Better CI for phat.par[i=0] + >>> Lp = Profile(phat, i=0) + >>> Lp.get_bounds(alpha=0.1) + array([ 0.94231243, 1.21444458]) + + >>> SF = 1./990 + >>> x = phat.isf(SF) + >>> x + 5.8114656626008818 + + # CI for x + >>> Lx = phat.profile(i=0, x=x, link=phat.dist.link) + >>> Lx.get_bounds(alpha=0.2) + array([ 4.91172017, 7.08081584]) + + # CI for logSF=log(SF) + >>> Lsf = phat.profile(i=0, logSF=log(SF), link=phat.dist.link) + >>> Lsf.get_bounds(alpha=0.2) + array([-8.37580767, -5.66897775]) + ''' + pass + + +if __name__ == "__main__": + import doctest + doctest.testmod() \ No newline at end of file