Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
740 B
2
Indexable
Never
def midpoint(lower_bound, upper_bound):
    return (lower_bound + upper_bound) / 2

def variance_grouped(data, frequencies):
    n = sum(frequencies)
    mean = sum(midpoint(data[i], data[i+1]) * frequencies[i] for i in range(len(data) - 1)) / n
    variance = sum(((midpoint(data[i], data[i+1]) - mean) ** 2) * frequencies[i] for i in range(len(data) - 1)) / n
    return variance

def standard_deviation_grouped(data, frequencies):
    return variance_grouped(data, frequencies) ** 0.5

data = [10, 20, 30, 40, 50]  # Class intervals
frequencies = [5, 8, 12, 10, 5]  # Frequencies of each class interval

result = standard_deviation_grouped(data, frequencies)
print("Measure of dispersion (standard deviation) for grouped data:", result)
Leave a Comment