Beispiel #1
0
 def __init__(self, rv, pdf, w=None, bbox=[None, None], k=1):
     """Constructor.
     """
     self.__rv = rv
     self.__pdf = pdf
     InterpolatedUnivariateSpline.__init__(self, rv, pdf, w, bbox, k)
     self.ppf = self.build_ppf()
 def __init__(self, x, y):
     """Constructor.
     """
     InterpolatedUnivariateSpline.__init__(self, x, y)
     ycdf = [self.integral(0, xcdf) for xcdf in x]
     self.cdf = InterpolatedUnivariateSpline(x, ycdf)
     self.ppf = InterpolatedUnivariateSpline(ycdf, x)
Beispiel #3
0
 def __init__(self, x, y, k=3):
     """Constructor.
     """
     InterpolatedUnivariateSpline.__init__(self, x, y, None, [None]*2, k)
     ycdf = np.array([self.integral(x[0], xcdf) for xcdf in x])
     self.cdf = InterpolatedUnivariateSpline(x, ycdf)
     mask=diff(ycdf) > 0.0
     mask=np.append(mask,False)
     #print(mask)
     #print(ycdf[mask])
     self.ppf = InterpolatedUnivariateSpline(ycdf[mask], x[mask])
Beispiel #4
0
 def __init__(self, x, y):
     # Richiamo il costruttore della classe madre
     InterpolatedUnivariateSpline.__init__(self, x, y)
     #Definisco la cdf (funzione cumulativa)
     y_cdf = np.array([self.integral(x[0], x_cdf) for x_cdf in x])
     self.cdf = InterpolatedUnivariateSpline(x, y_cdf)
     # Defiisco la ppf (percent-point function)
     x_ppf, i_ppf = np.unique(y_cdf,
                              return_index=True)  # se pdf non è monotona
     y_ppf = x[i_ppf]
     self.ppf = InterpolatedUnivariateSpline(x_ppf, y_ppf)
Beispiel #5
0
 def __init__(self, x, y, kind, bounds_error=False, fill_value=numpy.nan, copy=True):
   if copy:
     self.x = x.copy()
     self.y = y.copy()
   else:
     self.x = x
     self.y = y
   InterpolatedUnivariateSpline.__init__(self, self.x, self.y, k=kind)
   self.xmin = self.x[0]
   self.xmax = self.x[-1]
   self.fill_value = fill_value
   self.bounds_error = bounds_error
 def __init__(self, x, y):
     """Constructor.
     """
     InterpolatedUnivariateSpline.__init__(self, x, y)
     ycdf = np.array([self.integral(x[0], xcdf) for xcdf in x])
     self.cdf = InterpolatedUnivariateSpline(x, ycdf)
     # Need to make sure that the vector I am passing to the ppf spline as
     # the x values has no duplicates---and need to filter the y
     # accordingly.
     xppf, ippf = np.unique(ycdf, return_index=True)
     yppf = x[ippf]
     self.ppf = InterpolatedUnivariateSpline(xppf, yppf)
Beispiel #7
0
 def __init__(self, x, y, kind, bounds_error=False, fill_value=numpy.nan, copy=True):
   if copy:
     self.x = x.copy()
     self.y = y.copy()
   else:
     self.x = x
     self.y = y
   InterpolatedUnivariateSpline.__init__(self, self.x, self.y, k=kind)
   self.xmin = self.x[0]
   self.xmax = self.x[-1]
   self.fill_value = fill_value
   self.bounds_error = bounds_error
Beispiel #8
0
 def __init__(self,
              x,
              y,
              w=None,
              bbox=[None, None],
              k=3,
              xname=None,
              xunits=None,
              yname=None,
              yunits=None):
     """Constructor.
     """
     xUnivariateSplineBase.__init__(self, x, y, xname, xunits, yname,
                                    yunits)
     InterpolatedUnivariateSpline.__init__(self, self.x, self.y, w, bbox, k)
Beispiel #9
0
    def __init__(self, x, y):
        """Constructor.
        """
        InterpolatedUnivariateSpline.__init__(self, x, y)
        ycdf = np.array([self.integral(x[0], xcdf) for xcdf in x])
        self.cdf = InterpolatedUnivariateSpline(x, ycdf)

        # a=np.unique(ycdf)
        # print(ycdf.shape, a.shape)
        """Se ycdf non avesse valori identici, la lumghezza di a sara' uguale alla lunghezza di ycdf. Invece vedo che hanno una lunghezza diversa. Posso scrivere np.diff(ycdf) per stampare le differenze relative tra gli elementi contigui dell'array, e se lo stampo vedo che tutti gli ultimi elementi di ycdf sno uguali perche' li' la gaussiana e' piccola e sono tutti cosi vicini da essere uguali.
        Ora non posso banalmente sotituire a ad ycdf perche' x e a avrebbero lunghezza divera, devo fare in modo che abbiano lunghezze uguali.
        """
        #Need to make sure that the vector I am passing to the ppf spline as the
        # x values has no duplicates --- and need to filter the y accordingly
        """ In questo modo io creao un array _x senza valori doppi, np.unique mi ritorna il vettore senza valori doppi e un array di indici che mi dice i valori che non sono stati eliminati _i. in questo modo io posso usare gli indici _i per filtrare i valori di y eliminando i valori corrispondenti a queeli che np.unique ha tolto da ycdf.
        """
        _x, _i = np.unique(ycdf, return_index=True)
        _y = x[_i]
        self.ppf = InterpolatedUnivariateSpline(_x, _y)
Beispiel #10
0
 def __init__(
         self,   # Spline_eos instance
         P,      # Pressure function (usually the nominal eos)
         N=magic.spline_N,
         v_min=magic.spline_min,
         v_max=magic.spline_max,
         uncertainty=magic.spline_uncertainty,
         precondition=False,
         comment='',
         ):
     v = np.logspace(np.log10(v_min), np.log10(v_max), N)
     IU_Spline.__init__(self,v,P(v))
     self.prior_mean = self.get_c().copy()
     dev = self.prior_mean*uncertainty
     self.prior_var_inv = np.diag(1.0/(dev*dev))
     self.precondition = precondition
     if precondition:
         self.U_inv = np.diag(dev)
     return
Beispiel #11
0
 def __init__(self, x, y, w=None, bbox=[None, None], k=3,
              xname=None, xunits=None, yname=None, yunits=None):
     """Constructor.
     """
     xUnivariateSplineBase.__init__(self, x, y, xname, xunits, yname, yunits)
     InterpolatedUnivariateSpline.__init__(self, self.x, self.y, w, bbox, k)
Beispiel #12
0
 def __init__(self, x, y, comment=''):
     IU_Spline.__init__(self, x, y)
     Component.__init__(self, self.get_c(), comment)
Beispiel #13
0
 def __init__(self, x, y):
     InterpolatedUnivariateSpline.__init__(self, x, y)