Experiment 2 Code
Experiment 2 Code
Experiment 2 Code
def calculateStatistics(data):
stdDeviation = stdev(data)
dataVariance = variance(data)
return stdDeviation,dataVariance
data1 = [1, 2, 3, 4, 5, 4, 3, 2, 4, 5, 1, 2, 3, 4, 2, 5, 1, 3, 2, 1, 2, 1, 1, 1, 2]
data3 = [1, 2, 3, 10, 20, 30, 100, 200, 300, 1000, 2000, 3000]
data1stdDeviation,data1Variance = calculateStatistics(data1)
data2stdDeviation,data2Variance = calculateStatistics(data2)
data3stdDeviation,data3Variance = calculateStatistics(data3)
print('Variance: ',data1Variance)
print('Variance: ',data2Variance)
print('Variance: ',data3Variance)
Output:
For [1, 2, 3, 4, 5, 4, 3, 2, 4, 5, 1, 2, 3, 4, 2, 5, 1, 3, 2, 1, 2, 1, 1, 1, 2]
Variance: 1.9233333333333333
Variance: 159588.84333333332
For [1, 2, 3, 10, 20, 30, 100, 200, 300, 1000, 2000, 3000]
Variance: 948950.0909090909