Пример #1
0
def independent_gaussian_samples(lagged, num):
    shrunk_std = np.nanstd(list(lagged) + [0.01, -0.01])
    shrunk_mean = np.nanmean(lagged + [0.0])
    return [
        shrunk_mean + shrunk_std * StatsConventions.norminv(p)
        for p in evenly_spaced_percentiles(num)
    ]
Пример #2
0
def normal_sample(prediction_mean: float, prediction_std: float,
                  num: int) -> [float]:
    """ Returns normally distributed samples evenly spaced in probability """
    return [
        prediction_mean + prediction_std * StatsConventions.norminv(p)
        for p in evenly_spaced_percentiles(num=num)
    ]
 def to_zcurve(self, prctls: List[float]):
     """ A mapping from I^n -> R based on the Morton z-curve """
     SAFE = False
     dim = len(prctls)
     if dim == 1:
         return self.to_zscores(prctls)[0]
     else:
         zpercentile = self.from_cube(prctls=prctls)
         return StatsConventions.norminv(zpercentile)
 def to_zcurve(self, prctls: List[float] ):
     """ A mapping from R^n -> R based on the Morton z-curve """
     SAFE = False
     dim = len(prctls)
     if dim==1:
         return self.to_zscores(prctls)[0]
     else:
         SCALE = self.morton_scale(dim)
         int_prctls = [ int(math.floor(p*SCALE)) for p in prctls ]
         m1         = pymorton.interleave(*int_prctls)
         if SAFE:
             int_prctls_back = pymorton.deinterleave2(m1) if dim==2 else  pymorton.deinterleave3(m1)
             assert all( i1==i2 for i1,i2 in zip(int_prctls, int_prctls_back))
         m2         = pymorton.interleave(*[ SCALE-1 for _ in range(dim) ])
         zpercentile =  m1/m2
         return StatsConventions.norminv(zpercentile)
 def univariate_trivariate(trial):
     u = trial.suggest_float('u', 1e-6, 1 - 1e-6)
     z = StatsConventions.norminv(u)
     u2 = zc.from_zcurve(zvalue=z, dim=3)
     return objective(scale_me(u2, scale))[0]
Пример #6
0
 def univariate(u):
     z = StatsConventions.norminv(u)
     u2 = zc.from_zcurve(zvalue=z, dim=3)
     return objective(scale_me(u2,scale))[0]
Пример #7
0
 def inv_cdf(self, p: float) -> float:
     return self.mean + StatsConventions.norminv(p) * self.std()