コード例 #1
0
def confidence_interval(numbers):
    m = mean(numbers)
    confidence_level = 0.95
    z = (1-confidence_level) / 2
    sd = standard_deviation(numbers)
    n = squareroot(len(numbers))
    return [subtraction(multiplication(division(n, sd), z), m), addition(multiplication(division(n, sd), z), m)]
コード例 #2
0
def conf_interval(data):
    x = mean(data)
    dev = psd(data)
    z = 1.96  # for 95% confidence

    standard_error = division(dev, squareroot(len(data)))
    conf_upper_level = round(addition(x, multiplication(z, standard_error)), 2)
    conf_lower_level = round(subtraction(multiplication(z, standard_error), x), 2)
    return conf_upper_level, conf_lower_level
コード例 #3
0
def standard_deviation(numbers):  # complete
    n = len(numbers)
    c = 0
    t = 0
    for i in range(0, n, 1):
        c = subtraction(mean(numbers), numbers[i])
        t = addition(square(c), t)
    x = division((n - 1), t)
    return squareroot(x)
コード例 #4
0
def confidence_interval(data):
    z_value = 1.05
    mean =sample_mean(data)
    sd = pop_standard_dev(data)
    x = len(data)
    y = division(squareroot(x), sd)
    margin_of_error = multiplication(z_value, y)
    a = subtraction(mean, margin_of_error)
    b = addition(mean, margin_of_error)
    return a, b
コード例 #5
0
def ssd(data):
    total = 0
    sample = random.randint(1, len(data))
    new_sample = Getsample(data, sample)
    new_mean = mean(new_sample)
    for numb in new_sample:
        result = subtraction(numb, new_mean)
        sq = square(result)
        total = addition(total, sq)
    n = len(new_sample)
    d = division(subtraction(1, n), total)
    samp_sd = squareroot(d)
    return samp_sd
コード例 #6
0
def sample_st_deviation(data, sample_size):
    dev = 0
    sample = getSample(data, sample_size)
    sample_values = len(sample)
    x_bar = sample_mean()
    x = sample_values
    n = subtraction(sample_values, 1)
    for dev in sample:
        dev = subtraction(x, x_bar)
        square_x_bar = square(dev)
        add = addition(square_x_bar, square_x_bar)
        divide = division(add, n)
    return squareroot(divide)
コード例 #7
0
ファイル: Calculator.py プロジェクト: KashNJ21/calculator
 def squareroot(self, a):
     self.result = squareroot(a)
     return self.result
コード例 #8
0
def population_SD(data):
    SDvalue = squareroot(variance(data))
    return SDvalue
コード例 #9
0
def pop_standard_dev(data):
    n = len(data)
    u = population_mean(data)
    return squareroot(
        sum([(element - u)**2 for element in data]) / (len(data) - 1))
コード例 #10
0
ファイル: Psd.py プロジェクト: afarrag1207/CalculatorProject
def psd(numbers):
    return squareroot(variance(numbers))