Skip to content

Instantly share code, notes, and snippets.

@Adityanagraj
Created February 5, 2023 10:48
Show Gist options
  • Save Adityanagraj/d45f167b8711d6e78488abe1d9c177ee to your computer and use it in GitHub Desktop.
Save Adityanagraj/d45f167b8711d6e78488abe1d9c177ee to your computer and use it in GitHub Desktop.
2-6
import numpy as np
x=list(map(int,input().split(',')))
y=list(map(int,input().split(',')))
data1 = x#[3, 5, 5, 5, 8, 11, 11, 11, 13]
data2 = y#[ 3, 5, 5, 5, 8, 11, 11, 11, 20 ]
mean1 = np.mean(data1)
mean2 = np.mean(data2)
std1 = np.std(data1)
std2 = np.std(data2)
if mean1 > mean2 and std1 > std2:
print("Data 1 has a greater")
else:
print("Data 2 has a greater")
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
x=[3,5,5,5,8,11,11,11,13]
y=[3,5,5,5,8,11,11,11,20]
sns.histplot(data=x, bins=int(np.ceil(np.sqrt(len(x)))),label='x',color='g')
sns.histplot(data=y,bins=int(np.ceil(np.sqrt(len(y)))),label='y',color='y')
plt.show()
2-8
AM is always calculated by adding all the numbers and divde by number of integers
GM is always calculated by multiplying all the numbers and taking qube root of it
ex: having set of numbers 10,20,30
AM = (10+20+30)/3
GM = cuberoot(10*20*30)
2-9
When all terms in the set are the same, the AM and GM will be equal. This is because the product of equal numbers is equal to the square of each number, and the nth root of a number is equal to the number itself. Therefore, the GM is equal to the AM in this case. This can be mathematically proven as follows:
Let x be the common value of all terms in the set. Then the AM is given by (x + x + ... + x)/n = nx/n = x, and the GM is given by (x * x * ... * x)^(1/n) = x^n^(1/n) = x.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment