def __init__(self, n=None, epsilon=None, stdev=None, known_stdev=None, alpha=None, beta=None, power=None, hypothesis=None): if n is not None: is_integer(n, 'N') self.n = n else: self.n = None is_numeric(epsilon, 'epsilon') self.epsilon = epsilon is_positive(stdev, 'stdev') self.stdev = stdev self.theta = self.epsilon / self.stdev if known_stdev is not None: is_boolean(known_stdev, 'known_stdev') else: known_stdev = True self.known_stdev = known_stdev # Initialize the remaining arguments through the parent. super(MeansBase, self).__init__(alpha=alpha, power=power, beta=beta, hypothesis=hypothesis)
def __init__(self, n=None, mu=None, stdev=None, hypothesis=None, margin=None, alpha=None, beta=None, power=None, known_stdev=None): if n is not None: if isinstance(n, int): self.n = n else: raise ValueError('`n` should be of type Int.') else: self.n = None for value in mu: is_numeric(value, 'value') mu = [float(value) for value in mu] self.mu = mu self.n_groups = len(self.mu) if self.n_groups % 2 == 0: # If the number of groups is even, the Williams design is # equivalent to a n_groups by n_groups crossover design self.k = self.n_groups else: # Otherwise, it is equal to a 2*n_groups by n_groups crossover # design self.k = self.n_groups * 2 is_positive(stdev, 'stdev') self.stdev = stdev if known_stdev is not None: is_boolean(known_stdev, 'known_stdev') else: known_stdev = True self.known_stdev = known_stdev if margin is not None: is_numeric(margin, 'margin') else: margin = 0 self.margin = float(margin) # Initialize the remaining arguments (alpha, beta, power) # through the parent. super(MultiSampleWilliams, self).__init__(alpha=alpha, power=power, beta=beta, hypothesis=hypothesis)
def __init__(self, n=None, mu=None, stdev=None, comparison=None, known_stdev=None, alpha=None, beta=None, power=None): if n is not None: if isinstance(n, int): self.n = n else: raise ValueError('`n` should be of type Int.') else: self.n = None for value in mu: is_numeric(value, 'value') self.mu = mu self.mean_mu = statistics.mean(self.mu) self.n_groups = len(self.mu) # The number of comparisons of interest for pairwise comparisons self.tau = self.n_groups * (self.n_groups - 1) / 2.0 is_positive(stdev, 'stdev') self.stdev = stdev if comparison in ['simultaneous', 'pairwise']: self.comparison = comparison elif comparison is None: self.comparison = 'pairwise' else: raise ValueError(("`comparison` should be in ['simultaneous', " "'pairwise']")) if known_stdev is not None: is_boolean(known_stdev, 'known_stdev') else: known_stdev = True self.known_stdev = known_stdev # Initialize the remaining arguments (alpha, beta, power) # through the parent. super(OneWayAnova, self).__init__(alpha=alpha, power=power, beta=beta, hypothesis='equality')
def __init__(self, n=None, alpha=None, beta=None, power=None, p_11=None, p_12=None, p_21=None, p_22=None, gamma=None, stdev_1=None, stdev_2=None): if gamma is None: is_in_0_1(p_11, 'p_11 should be in [0, 1].') is_in_0_1(p_12, 'p_12 should be in [0, 1].') is_in_0_1(p_21, 'p_21 should be in [0, 1].') is_in_0_1(p_22, 'p_22 should be in [0, 1].') gamma = (math.log(p_11 / (1 - p_11)) + math.log(p_12 / (1 - p_12)) - math.log(p_21 / (1 - p_21)) - math.log(p_22 / (1 - p_22))) else: is_numeric(gamma, '`gamma` should be a number.') if n is not None: is_integer(n, '`n` should be of type Int.') self.n = n is_positive(stdev_1, 'stdev_1') self.stdev_1 = stdev_1 is_positive(stdev_2, 'stdev_2') self.stdev_2 = stdev_2 self.theta = gamma / math.sqrt(stdev_1**2 + stdev_2**2) # Set remaining variables. super(CarryOverEffect, self).__init__(alpha=alpha, beta=beta, power=power)
def __init__(self, delta=None, stdev_wr=None, stdev_wt=None, stdev_br=None, stdev_bt=None, theta_BE=None, m_plus=None, alpha=None, power=None, beta=None): is_numeric(delta, 'delta') self.delta = delta is_positive(stdev_wr, 'stdev_wr') self.stdev_wr = stdev_wr is_positive(stdev_wt, 'stdev_wt') self.stdev_wt = stdev_wt is_positive(stdev_bt, 'stdev_bt') self.stdev_bt = stdev_bt is_positive(stdev_br, 'stdev') self.stdev_br = stdev_br if theta_BE is None: theta_BE = 1 else: is_positive(theta_BE, 'theta_BE') self.theta_BE = theta_BE if m_plus is None: m_plus = MAX_ITERATIONS else: is_integer(m_plus, 'm_plus') self.m_plus = m_plus # Initialize the remaining arguments through the parent. super(InVitro, self).__init__(hypothesis="equivalence", alpha=alpha, beta=beta, power=power)
def __init__(self, delta=None, stdev_wr=None, stdev_wt=None, stdev_br=None, stdev_bt=None, rho=None, theta_IBE=None, alpha=None, power=None, beta=None): is_numeric(delta, 'delta') self.delta = delta is_positive(stdev_wr, 'stdev_wr') self.stdev_wr = stdev_wr is_positive(stdev_wt, 'stdev_wt') self.stdev_wt = stdev_wt is_positive(stdev_bt, 'stdev_br') self.stdev_br = stdev_br is_positive(stdev_bt, 'stdev_bt') self.stdev_bt = stdev_bt is_in_0_1(rho, 'rho') self.rho = rho var_d = self.stdev_bt**2 + self.stdev_br**2 - 2 * self.rho * self.stdev_bt**2 * self.stdev_bt**2 self.stdev_d = math.sqrt(var_d) if theta_IBE is None: theta_IBE = 1.74 else: is_positive(theta_IBE, 'theta_IBE') self.theta_IBE = theta_IBE # Initialize the remaining arguments through the parent. super(Individual, self).__init__(hypothesis="equivalence", alpha=alpha, beta=beta, power=power)
def __init__(self, delta=None, l=None, stdev_11=None, stdev_tt=None, stdev_tr=None, stdev_bt=None, stdev_br=None, rho=None, theta_PBE=None, alpha=None, power=None, beta=None): if delta is None: delta = 0 else: is_numeric(delta, 'delta') self.delta = delta is_numeric(l, 'l') self.l = l is_positive(stdev_11, 'stdev_11') self.stdev_11 = stdev_11 is_positive(stdev_tt, 'stdev_tt') self.stdev_tt = stdev_tt is_positive(stdev_tr, 'stdev_tr') self.stdev_tr = stdev_tr is_positive(stdev_bt, 'stdev_bt') self.stdev_bt = stdev_bt is_positive(stdev_br, 'stdev') self.stdev_br = stdev_br is_in_0_1(rho, 'rho') self.rho = rho if theta_PBE is None: theta_PBE = 1.74 else: is_positive(theta_PBE, 'theta_PBE') self.theta_PBE = theta_PBE # Initialize the remaining arguments through the parent. super(Population, self).__init__(hypothesis="equivalence", alpha=alpha, beta=beta, power=power)
def __init__(self, n=None, mu_1=None, mu_2=None, stdev=None, known_stdev=None, hypothesis=None, margin=None, alpha=None, beta=None, power=None): is_numeric(mu_1, 'mu_1') is_numeric(mu_2, 'mu_2') if margin is not None: is_numeric(margin, 'margin') else: margin = 0 epsilon = mu_1 - mu_2 epsilon = float(mu_1) - float(mu_2) if hypothesis is 'superiority': epsilon = epsilon + float(margin) elif hypothesis is 'equivalence': # This should be margin - abs(epsilon), but the abs() is taken care # of when epsilon is set for generality purposes epsilon = float(margin) - abs(epsilon) epsilon *= math.sqrt(2) # Initialize the remaining arguments through the parent. super(TwoSampleCrossover, self).__init__(n=n, epsilon=epsilon, stdev=stdev, known_stdev=known_stdev, alpha=alpha, beta=beta, power=power, hypothesis=hypothesis)
def __init__(self, n=None, mu=None, mu_0=None, stdev=None, known_stdev=None, hypothesis=None, margin=None, alpha=None, beta=None, power=None): is_numeric(mu, 'mu') is_numeric(mu_0, 'mu_0') if margin is not None: is_numeric(margin, 'margin') # Ensure that the values are floats epsilon = abs(float(mu) - float(mu_0)) if hypothesis is 'superiority': epsilon = epsilon - float(margin) elif hypothesis is 'equivalence': epsilon = float(margin) - abs(epsilon) # Initialize the remaining arguments through the parent. super(OneSample, self).__init__(n=n, epsilon=epsilon, stdev=stdev, known_stdev=known_stdev, alpha=alpha, beta=beta, power=power, hypothesis=hypothesis)
def __init__(self, ratio=None, n_1=None, n_2=None, mu_1=None, mu_2=None, stdev=None, known_stdev=None, hypothesis=None, margin=None, alpha=None, beta=None, power=None): # n is only used to help with control flow if ratio is None: if n_1 is None: ratio = 1 if n_2 is None: n = None else: n_1 = n_2 n = n_1 + n_2 else: if n_2 is None: ratio = 1 n_2 = n_1 n = n_1 + n_2 else: n = n_1 + n_2 ratio = n_1 / float(n_2) else: if n_1 is None: if n_2 is None: n = None else: n_1 = math.ceil(ratio * n_2) n = n_1 + n_2 else: if n_2 is None: n_2 = math.ceil(n_1 / ratio) n = n_1 + n_2 else: n = n_1 + n_2 self.n_1 = n_1 self.n_2 = n_2 self.ratio = float(ratio) stdev *= math.sqrt(1 + 1 / float(ratio)) is_numeric(mu_1, 'mu_1') is_numeric(mu_2, 'mu_2') if margin is not None: is_numeric(margin, 'margin') epsilon = float(mu_1) - float(mu_2) if hypothesis is 'superiority': epsilon = epsilon + float(margin) elif hypothesis is 'equivalence': # This should be margin - abs(epsilon), but the abs() is taken care # of when epsilon is set for generality purposes epsilon = float(margin) - abs(epsilon) # Initialize the remaining arguments through the parent. super(TwoSampleParallel, self).__init__(n=n, epsilon=epsilon, stdev=stdev, known_stdev=known_stdev, alpha=alpha, beta=beta, power=power, hypothesis=hypothesis)