|  |  | @ -183,9 +183,9 @@ class LevelCrossings(WafoData): | 
			
		
	
		
		
			
				
					
					|  |  |  |                 u_min = self.args[i.min()] |  |  |  |                 u_min = self.args[i.min()] | 
			
		
	
		
		
			
				
					
					|  |  |  |             if u_max is None: |  |  |  |             if u_max is None: | 
			
		
	
		
		
			
				
					
					|  |  |  |                 u_max = self.args[i.max()]  |  |  |  |                 u_max = self.args[i.max()]  | 
			
		
	
		
		
			
				
					
					|  |  |  |            |  |  |  |         lcf, lcx = self.data, self.args | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        # Extrapolate LC for high levels |  |  |  |         # Extrapolate LC for high levels | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        [lcEst.High,Est.High] = self._extrapolate(lc,u_max,u_max-lc_max,method, dist); |  |  |  |         [lcEst.High,Est.High] = self._extrapolate(lcx,lcf,u_max,u_max-lc_max,method, dist); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | #         |  |  |  | #         | 
			
		
	
		
		
			
				
					
					|  |  |  | #        # Extrapolate LC for low levels |  |  |  | #        # Extrapolate LC for low levels | 
			
		
	
		
		
			
				
					
					|  |  |  | #         |  |  |  | #         | 
			
		
	
	
		
		
			
				
					|  |  | @ -199,137 +199,120 @@ class LevelCrossings(WafoData): | 
			
		
	
		
		
			
				
					
					|  |  |  | #          semilogx(lc(:,2),lc(:,1),lcEst.High(:,2),lcEst.High(:,1),lcEst.Low(:,2),lcEst.Low(:,1)) |  |  |  | #          semilogx(lc(:,2),lc(:,1),lcEst.High(:,2),lcEst.High(:,1),lcEst.Low(:,2),lcEst.Low(:,1)) | 
			
		
	
		
		
			
				
					
					|  |  |  | #        end |  |  |  | #        end | 
			
		
	
		
		
			
				
					
					|  |  |  | #         |  |  |  | #         | 
			
		
	
		
		
			
				
					
					|  |  |  |         ### |  |  |  |         ## | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #    def _extrapolate(self, lcx,lcf,u,offset,method,dist) |  |  |  |     def _extrapolate(self, lcx,lcf,u,offset,method,dist): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        # Extrapolate the level crossing spectra for high levels |  |  |  |         # Extrapolate the level crossing spectra for high levels | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        method = method.lower() |  |  |  |         method = method.lower() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        dist = dist.lower() |  |  |  |         dist = dist.lower() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            |  |  |  |             | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        # Excedences over level u |  |  |  |         # Excedences over level u | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        Iu = lcx>u; |  |  |  |         Iu = lcx>u; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        lcx1, lcf1 = lcx[Iu], lcf[Iu] |  |  |  |         lcx1, lcf1 = lcx[Iu], lcf[Iu] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        lcf3,lcx3 = _make_increasing(lcf1[::-1],lcx1[::-1]) |  |  |  |         lcf2,lcx2 = _make_increasing(lcf1[::-1],lcx1[::-1]) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |          | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        # Corrected by PJ 17-Feb-2004 |  |  |  |         nim1 = 0  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        lc3=[0 0; lc3];  |  |  |  |         x=[] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        x=[]; |  |  |  |         for k, ni in enumerate(lcf2.tolist()):  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        for k=2:length(lc3(:,1)) |  |  |  |             nk = ni - nim1  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            nk = lc3(k,2)-lc3(k-1,2); |  |  |  |             x.append(ones(nk)*lcx2[k]) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            x = [x; ones(nk,1)*lc3(k,1)]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            #end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #        x = x-u;    |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #        # Estimate tail |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #        if dist=='genpareto':  |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              genpareto = distributions.genpareto |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              phat = genpareto.fit2(x, floc=0, method=method) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            Est.k = phat.params(1); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            Est.s = phat.params(2); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            if isnan(phat.fixpar(3)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##              Est.cov = phat.covariance; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            else |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##              Est.cov = phat.covariance(1:2,1:2); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            if Est.k>0, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##              Est.UpperLimit = u+Est.s/Est.k; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ##            end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            df = 0.01     |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            xF = np.arange(0.0,4+df/2,df) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            F = phat.cdf(xF) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.lcu = interp1(lcx,lcf,u)+1 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            # Calculate 90 # confidence region, an ellipse, for (k,s) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            [B,D] = eig(Est.cov); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            b = [Est.k; Est.s]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            r = sqrt(-2*log(1-90/100)); # 90 # confidence sphere |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            Nc = 16+1; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            ang = linspace(0,2*pi,Nc); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            c0 = [r*sqrt(D(1,1))*sin(ang); r*sqrt(D(2,2))*cos(ang)]; # 90# Circle |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #        #    plot(c0(1,:),c0(2,:)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            c1 = B*c0+b*ones(1,length(c0)); # Transform to ellipse for (k,s) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #        #    plot(c1(1,:),c1(2,:)), hold on |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            # Calculate conf.int for lcu |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            # Assumtion: lcu is Poisson distributed |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            # Poissin distr. approximated by normal when calculating conf. int. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            dXX = 1.64*sqrt(Est.lcu); # 90 # quantile for lcu |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            lcEstCu = zeros(length(xF),Nc);  |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            lcEstCl = lcEstCu; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #            for i=1:Nc |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              k=c1(1,i); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              s=c1(2,i); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              F2 = cdfgenpar(xF,k,s); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              lcEstCu(:,i) = (Est.lcu+dXX)*(1-F2); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | #              lcEstCl(:,i) = (Est.lcu-dXX)*(1-F2); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             #end |  |  |  |             #end | 
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            lcEstCI = [min(lcEstCl')' max(lcEstCu')']; |  |  |  |         x = np.hstack(x)-u    | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |            | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            lcEst = [xF+u Est.lcu*(1-F) lcEstCI]; |  |  |  |         # Estimate tail | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |            | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #          case 'exp' |  |  |  |         if dist=='genpareto':  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             genpareto = distributions.genpareto | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            n = length(x); |  |  |  |             phat = genpareto.fit2(x, floc=0, method=method) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            s = mean(x); |  |  |  |                | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            cov = s/n; |  |  |  |             df = 0.01     | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.s = s; |  |  |  |             xF = np.arange(0.0,4+df/2,df) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.cov = cov; |  |  |  |             F = phat.cdf(xF) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             lcu = np.interp(u,lcx,lcf)+1 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            xF = (0.0:0.01:4)'; |  |  |  |             covar = phat.par_cov[::2,::2] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            F = 1-exp(-xF/s); |  |  |  |             # Calculate 90 # confidence region, an ellipse, for (k,s) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.lcu = interp1(lc(:,1),lc(:,2),u)+1; |  |  |  |             B, D = np.linalg.eig(covar); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             b = phat.par[::2]  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            lcEst = [xF+u Est.lcu*(1-F)]; |  |  |  |             if b[0]>0: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |                 upperlimit = u + b[1]/b[0] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #          case 'ray' |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             r = sqrt(-2*log(1-90/100)); # 90 # confidence sphere | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            n = length(x); |  |  |  |             Nc = 16+1; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Sx = sum((x+offset).^2-offset^2); |  |  |  |             ang = linspace(0,2*pi,Nc); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            s=sqrt(Sx/n);  # Shape parameter |  |  |  |             c0 = np.vstack((r*sqrt(D[0,0])*sin(ang), r*sqrt(D[1,1])*cos(ang))) # 90# Circle | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |         #    plot(c0(1,:),c0(2,:)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.s = s; |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.cov = NaN; |  |  |  |             c1 = B*c0+b*ones((1,len(c0))); # Transform to ellipse for (k,s) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |         #    plot(c1(1,:),c1(2,:)), hold on | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            xF = (0.0:0.01:4)'; |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            F = 1 - exp(-((xF+offset).^2-offset^2)/s^2); |  |  |  |             # Calculate conf.int for lcu | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            Est.lcu = interp1(lc(:,1),lc(:,2),u)+1; |  |  |  |             # Assumtion: lcu is Poisson distributed | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             # Poissin distr. approximated by normal when calculating conf. int. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            lcEst = [xF+u Est.lcu*(1-F)]; |  |  |  |             dXX = 1.64*sqrt(lcu); # 90 # quantile for lcu | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #          otherwise |  |  |  |             lcEstCu = zeros((len(xF),Nc));  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             lcEstCl = lcEstCu; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            error(['Unknown method: ' method]); |  |  |  |             for i in range(Nc): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |                 k=c1[0,i] | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 s=c1[2,i] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 F2 = genpareto.cdf(xF,k,scale=s) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 lcEstCu[:,i] = (lcu+dXX)*(1-F2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 lcEstCl[:,i] = (lcu-dXX)*(1-F2); | 
			
		
	
		
		
			
				
					
					|  |  |  |             #end |  |  |  |             #end | 
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #             |  |  |  |             lcEstCI = [min(lcEstCl), max(lcEstCu)] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        ## End extrapolate |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |             lcEst = [xF+u, lcu*(1-F), lcEstCI]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #        def _make_increasing(f, t=None): |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            # Makes the signal x strictly increasing.  |  |  |  |         elif dist=='expon': | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            # |  |  |  |             n = len(x) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            # x = two column matrix with times in first column and values in the second. |  |  |  |             s = mean(x); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |             cov = s/n; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            n = len(f) |  |  |  |             Est.s = s; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            if t is None: |  |  |  |             Est.cov = cov; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #                t = np.arange(n) |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            ff = [] |  |  |  |             xF = np.arange(0.0,4+df/2,df) #xF = (0.0:0.01:4)'; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            tt = [] |  |  |  |             F = -expm1(-xF/s) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            ff.append(f[0]) |  |  |  |             lcu = np.interp(u,lcx,lcf)+1 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            tt.append(t[0]) |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #         |  |  |  |             lcEst = [xF+u, Est.lcu*(1-F)] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            for i in xrange(1,n): |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #                if f[i]>ff[-1] |  |  |  |         elif dist== 'ray': | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #                    ff.append(f[i]) |  |  |  |              | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #                    tt.append(t[i]) |  |  |  |             n = len(x) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #           |  |  |  |             Sx = sum((x+offset)**2-offset**2) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | #            return np.asarray(ff), np.asarray(tt) |  |  |  |             s = sqrt(Sx/n);  # Shape parameter | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             cov = NaN; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             xF = np.arange(0.0,4+df/2,df) #xF = (0.0:0.01:4)'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             F = -expm1(-((xF+offset)**2-offset**2)/s**2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             lcu = np.interp(u,lcx,lcf,u)+1 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             lcEst = [xF+u, Est.lcu*(1-F)]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         else:  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             raise ValueError() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |            | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         ## End extrapolate | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |            | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         def _make_increasing(f, t=None): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             # Makes the signal f strictly increasing.  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             n = len(f) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             if t is None: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 t = np.arange(n) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             ff = [f[0],] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             tt = [t[0],] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             for i in xrange(1,n): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if f[i]>ff[-1]: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     ff.append(f[i]) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     tt.append(t[i]) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |            | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return np.asarray(ff), np.asarray(tt) | 
			
		
	
		
		
			
				
					
					|  |  |  |           |  |  |  |           | 
			
		
	
		
		
			
				
					
					|  |  |  |     def sim(self, ns, alpha): |  |  |  |     def sim(self, ns, alpha): | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |         """ | 
			
		
	
	
		
		
			
				
					|  |  | 
 |