You are viewing a single comment's thread. Return to all comments →
import numpy as np from collections import Counter import math
n = int(input()) array = np.array(input().split(),int)
mean = round(np.mean(array),1) median = round(np.median(array),1) std = round(np.std(array),1)
count = Counter(array) max_count = max(count.values())
mode = min([num for num, freq in count.items() if freq == max_count])
def calculate_confidence_interval(mean, std, N, z_score=1.96): lower_confidence = round((mean - z_score * (std / math.sqrt(N))), 1) upper_confidence = round((mean + z_score * (std / math.sqrt(N))), 1) return lower_confidence, upper_confidence
lower, upper = calculate_confidence_interval(mean, std, n)
print(mean) print(median) print(mode) print(std) print(lower, upper)
Seems like cookies are disabled on this browser, please enable them to open this website
Basic Statistics Warmup
You are viewing a single comment's thread. Return to all comments →
import numpy as np from collections import Counter import math
n = int(input()) array = np.array(input().split(),int)
mean = round(np.mean(array),1) median = round(np.median(array),1) std = round(np.std(array),1)
count = Counter(array) max_count = max(count.values())
mode = min([num for num, freq in count.items() if freq == max_count])
def calculate_confidence_interval(mean, std, N, z_score=1.96): lower_confidence = round((mean - z_score * (std / math.sqrt(N))), 1) upper_confidence = round((mean + z_score * (std / math.sqrt(N))), 1) return lower_confidence, upper_confidence
lower, upper = calculate_confidence_interval(mean, std, n)
print(mean) print(median) print(mode) print(std) print(lower, upper)