Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
422 B
1
Indexable
Never
def calculate_skewness(data):
    n = len(data)
    mean = sum(data) / n
    diff_cubed = [(x - mean) ** 3 for x in data]
    numerator = sum(diff_cubed)
    denominator = (sum([(x - mean) ** 2 for x in data]) / n) ** (3 / 2)
    
    return numerator / denominator if denominator != 0 else 0

# Example usage:
your_data = [1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9]
result = calculate_skewness(your_data)
print("Skewness:", result)
Leave a Comment