Conflicts:
	wafo/spectrum/core.py
master
pbrod 9 years ago
commit 8ba9e7e1a2

@ -1429,6 +1429,10 @@ class SpecData1D(PlotData):
>>> f = S.to_t_pdf(pdef='Tc', paramt=(0, 10, 51), speed=7) >>> f = S.to_t_pdf(pdef='Tc', paramt=(0, 10, 51), speed=7)
>>> S = sm.Jonswap(4*pi/Tp, Hm0=7, Tp=11) >>> S = sm.Jonswap(4*pi/Tp, Hm0=7, Tp=11)
>>> Hm0 = 7
>>> Tp = 11
>>> S = sm.Jonswap(4*pi/Tp,[Hm0, Tp])
Sk = spec2spec(S,'k1d') Sk = spec2spec(S,'k1d')
L0 = spec2mom(S,1) L0 = spec2mom(S,1)
paramu = [sqrt(L0)*[-4 4] 41] paramu = [sqrt(L0)*[-4 4] 41]

@ -329,32 +329,32 @@ def nlogps(self, theta, x):
def _penalized_nnlf(self, theta, x): def _penalized_nnlf(self, theta, x):
''' Return negative loglikelihood function, ''' Return negative loglikelihood function,
i.e., - sum (log pdf(x, theta), axis=0) i.e., - sum (log pdf(x, theta), axis=0)
where theta are the parameters (including loc and scale) where theta are the parameters (including loc and scale)
''' '''
try: try:
loc = theta[-2] loc = theta[-2]
scale = theta[-1] scale = theta[-1]
args = tuple(theta[:-2]) args = tuple(theta[:-2])
except IndexError: except IndexError:
raise ValueError("Not enough input arguments.") raise ValueError("Not enough input arguments.")
if not self._argcheck(*args) or scale <= 0: if not self._argcheck(*args) or scale <= 0:
return inf return inf
x = asarray((x-loc) / scale) x = asarray((x-loc) / scale)
N = len(x)
loginf = log(_XMAX) cond0 = (x < self.a) | (self.b < x)
Nbad = sum(cond0)
if np.isneginf(self.a).all() and np.isinf(self.b).all(): if Nbad > 0:
Nbad = 0 x = argsreduce(~cond0, x)[0]
else: logpdf = self._logpdf(x, *args)
cond0 = (x < self.a) | (self.b < x) finite_logpdf = np.isfinite(logpdf)
Nbad = sum(cond0) Nbad += np.sum(~finite_logpdf, axis=0)
if Nbad > 0: logscale = N * log(scale)
x = argsreduce(~cond0, x)[0] if Nbad > 0:
penalty = Nbad * log(_XMAX) * 100
N = len(x) return -np.sum(logpdf[finite_logpdf], axis=0) + penalty + logscale
return self._nnlf(x, *args) + N*log(scale) + Nbad * 100.0 * loginf return -np.sum(logpdf, axis=0) + logscale
def _reduce_func(self, args, options): def _reduce_func(self, args, options):

Loading…
Cancel
Save