Exemple #1
0
    def _trdata_cdf(self, data):
        '''
        Estimate transformation, g, from observed marginal CDF.
        Assumption: a Gaussian process, Y, is related to the
                            non-Gaussian process, X, by Y = g(X).
        Parameters
        ----------
        options = options structure defining how the smoothing is done.
                     (See troptset for default values)
        Returns
        -------
        tr, tr_emp  = smoothed and empirical estimate of the transformation g.

        The empirical CDF is usually very irregular. More than one local
        maximum of the empirical CDF may cause poor fit of the transformation.
        In such case one should use a smaller value of GSM or set a larger
        variance for GVAR.  If X(t) is likely to cross levels higher than 5
        standard deviations then the vector param has to be modified. For
        example if X(t) is unlikely to cross a level of 7 standard deviations
        one can use  param = [-7 7 513].
        '''
        mean = data.mean()
        sigma = data.std()
        cdf = edf(data.ravel())
        Ne = self.ne
        nd = len(cdf.data)
        if nd > self.ntr and self.ntr > 0:
            x0 = np.linspace(cdf.args[Ne], cdf.args[nd - 1 - Ne], self.ntr)
            cdf.data = np.interp(x0, cdf.args, cdf.data)
            cdf.args = x0
            Ne = 0
        uu = np.linspace(*self.param)

        ncr = len(cdf.data)
        ng = len(np.atleast_1d(self.gvar))
        if ng == 1:
            gvar = self.gvar * np.ones(ncr)
        else:
            self.gvar = np.atleast_1d(self.gvar)
            gvar = np.interp(np.linspace(0, 1, ncr), np.linspace(0, 1, ng),
                             self.gvar.ravel())

        ind = np.flatnonzero(np.diff(cdf.args) > 0)  # remove equal points
        nd = len(ind)
        ind1 = ind[Ne:nd - Ne]
        tmp = invnorm(cdf.data[ind])

        x = sigma * uu + mean
        pp_tr = SmoothSpline(cdf.args[ind1],
                             tmp[Ne:nd - Ne],
                             p=self.gsm,
                             lin_extrap=self.linextrap,
                             var=gvar[ind1])
        tr = TrData(pp_tr(x), x, mean=mean, sigma=sigma)
        tr_emp = TrData(tmp, cdf.args[ind], mean=mean, sigma=sigma)
        tr_emp.setplotter('step')

        if self.chkder:
            tr_raw = TrData(tmp[Ne:nd - Ne],
                            cdf.args[ind1],
                            mean=mean,
                            sigma=sigma)
            tr = self._check_tr(tr, tr_raw)

        if self.plotflag > 0:
            tr.plot()
            tr_emp.plot()
        return tr, tr_emp
Exemple #2
0
plt.show()

#!#!
plt.clf()#
fac = wk.TKDE(Ac,L2=L2)(np.linspace(0.01,3,200), output='plot')
fac.plot()
# wafostamp([],'(ER)')
print(fac.integrate(a=0.01, b=3))
print(fac.integrate())
print('Block = 8'),
# pause(pstate)

#!#! Empirical crest height CDF
plt.clf()
Fac = fac.to_cdf()
Femp = ws.edf(Ac)
Fac.plot()
Femp.plot()
plt.axis([0, 2, 0, 1])

#wafostamp([],'(ER)')
#disp('Block = 9'), pause(pstate)

#!#! Empirical crest height CDF compared to a Transformed Rayleigh approximation

# facr = trraylpdf(fac.x{1},'Ac',grec1);
# Facr = cumtrapz(facr.x{1},facr.f);
# hold on
# plot(facr.x{1},Facr,'.')
# axis([1.25 2.25 0.95 1])
# wafostamp([],'(ER)')
Exemple #3
0
    def _trdata_cdf(self, data):
        '''
        Estimate transformation, g, from observed marginal CDF.
        Assumption: a Gaussian process, Y, is related to the
                            non-Gaussian process, X, by Y = g(X).
        Parameters
        ----------
        options = options structure defining how the smoothing is done.
                     (See troptset for default values)
        Returns
        -------
        tr, tr_emp  = smoothed and empirical estimate of the transformation g.

        The empirical CDF is usually very irregular. More than one local
        maximum of the empirical CDF may cause poor fit of the transformation.
        In such case one should use a smaller value of GSM or set a larger
        variance for GVAR.  If X(t) is likely to cross levels higher than 5
        standard deviations then the vector param has to be modified. For
        example if X(t) is unlikely to cross a level of 7 standard deviations
        one can use  param = [-7 7 513].
        '''
        mean = data.mean()
        sigma = data.std()
        cdf = edf(data.ravel())
        Ne = self.ne
        nd = len(cdf.data)
        if nd > self.ntr and self.ntr > 0:
            x0 = np.linspace(cdf.args[Ne], cdf.args[nd - 1 - Ne], self.ntr)
            cdf.data = np.interp(x0, cdf.args, cdf.data)
            cdf.args = x0
            Ne = 0
        uu = np.linspace(*self.param)

        ncr = len(cdf.data)
        ng = len(np.atleast_1d(self.gvar))
        if ng == 1:
            gvar = self.gvar * np.ones(ncr)
        else:
            self.gvar = np.atleast_1d(self.gvar)
            gvar = np.interp(np.linspace(0, 1, ncr),
                             np.linspace(0, 1, ng), self.gvar.ravel())

        ind = np.flatnonzero(np.diff(cdf.args) > 0)  # remove equal points
        nd = len(ind)
        ind1 = ind[Ne:nd - Ne]
        tmp = invnorm(cdf.data[ind])

        x = sigma * uu + mean
        pp_tr = SmoothSpline(cdf.args[ind1], tmp[Ne:nd - Ne], p=self.gsm,
                             lin_extrap=self.linextrap, var=gvar[ind1])
        tr = TrData(pp_tr(x), x, mean=mean, sigma=sigma)
        tr_emp = TrData(tmp, cdf.args[ind], mean=mean, sigma=sigma)
        tr_emp.setplotter('step')

        if self.chkder:
            tr_raw = TrData(tmp[Ne:nd - Ne], cdf.args[ind1], mean=mean,
                             sigma=sigma)
            tr = self._check_tr(tr, tr_raw)

        if self.plotflag > 0:
            tr.plot()
            tr_emp.plot()
        return tr, tr_emp
Exemple #4
0
plt.show()

#!#!
plt.clf()  #
fac = wk.TKDE(Ac, L2=L2)(np.linspace(0.01, 3, 200), output='plot')
fac.plot()
# wafostamp([],'(ER)')
print(fac.integrate(a=0.01, b=3))
print(fac.integrate())
print('Block = 8'),
# pause(pstate)

#!#! Empirical crest height CDF
plt.clf()
Fac = fac.to_cdf()
Femp = ws.edf(Ac)
Fac.plot()
Femp.plot()
plt.axis([0, 2, 0, 1])

#wafostamp([],'(ER)')
#disp('Block = 9'), pause(pstate)

#!#! Empirical crest height CDF compared to a Transformed Rayleigh approximation

# facr = trraylpdf(fac.x{1},'Ac',grec1);
# Facr = cumtrapz(facr.x{1},facr.f);
# hold on
# plot(facr.x{1},Facr,'.')
# axis([1.25 2.25 0.95 1])
# wafostamp([],'(ER)')