コード例 #1
0
 def calc_mode_manual(self, loc=0.0, scale=1.0):
     shape = np.array(self.df).shape
     dfmax = np.array(self.df * np.ones((1,)), dtype='i')
     dfmax = (dfmax.flatten() - 2).tolist()
     for id in range(len(dfmax)):
         dfmax[id] = np.max([dfmax[id], 0])
     return np.reshape(dfmax, shape) + make_int(np.around(loc))
コード例 #2
0
 def __init__(self, **params):
     self.type = ProbabilityDistributionTypes.CHISQUARE
     self.scipy_name = "chi"
     self.numpy_name = ProbabilityDistributionTypes.CHISQUARE
     self.constraint_string = "int(df) > 0"
     self.df = make_int(params.get("df", 1))
     self.__update_params__(df=self.df)
コード例 #3
0
 def __init__(self, **params):
     self.type = ProbabilityDistributionTypes.BINOMIAL
     self.scipy_name = "binom"
     self.numpy_name = ProbabilityDistributionTypes.BINOMIAL
     self.constraint_string = "n > 0 and 0 < p < 1"
     self.n = make_int(params.get("n", 1))
     self.p = make_float(params.get("p", 0.5))
     self.__update_params__(n=self.n, p=self.p)
コード例 #4
0
 def calc_mode_manual(self, loc=0.0, scale=1.0):
     loc = make_int(np.round(loc))
     p = np.array(self.p)
     shape = p.shape
     mode = np.ones(np.array(p * np.ones((1,))).shape, dtype="i") + loc
     mode[np.where(p < 0.5)[0]] = 1 + loc
     p05 = p == 0.5
     if np.any(p05):
         self.logger.warning("The mode of bernoulli distribution for p=0.5 consists of two values (0.0 + loc and 1.0 + loc)!")
         mode = mode.astype('O')
         mode[np.where(p05)[0]] = [[0.0 + loc, 1.0 + loc]]
     return mode
コード例 #5
0
 def calc_mean_manual(self, loc=0.0, scale=1.0):
     return self.df + make_int(np.around(loc))
コード例 #6
0
 def update_params(self, loc=0.0, scale=1.0, use="scipy", **params):
     self.__update_params__(loc, scale, use,
                            df=make_int(params.get("df", self.df)))
コード例 #7
0
 def calc_mode_manual(self, loc=0.0, scale=1.0):
     return make_int(np.round((self.n + 1) * self.p + loc) - 1)
コード例 #8
0
 def calc_median_manual(self, loc=0.0, scale=1.0):
     return make_int(np.round(self.calc_mean_manual(loc=loc)))
コード例 #9
0
 def update_params(self, loc=0.0, scale=1.0, use="scipy", **params):
     self.__update_params__(loc,
                            scale,
                            use,
                            n=make_int(params.get("n", self.n)),
                            p=make_float(params.get("p", self.p)))
コード例 #10
0
 def calc_mode_manual(self, loc=0.0, scale=1.0):
     return [
         make_int(np.round(self.lamda + loc)) - 1,
         make_int(np.round(self.lamda + loc))
     ]