In: Computer Science
Generate a sample of 1000 random floating numbers (from 0 to 1) using numpy. Then plot it and compare with a normal distribution plot close to that region (from 0 to 1) as well. Hint: Using Seaborn module
#importing the libraries
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# generating random 1000 float values between 0 and 1
x = np.random.randn(1000)
sns.distplot(x, color ='red')
plt.show()
# generating normal distributed data between 0 and 1 and plotting it using seaborn
normal_distributed_data = np.random.normal(0, 1, 1000)
sns.distplot(normal_distributed_data, color ='red')
plt.show()
# Comaprison between both the normal distributed data and random float values between 0 and 1
normal_distributed_data = np.random.normal(0, 1, 1000)
sns.distplot(normal_distributed_data, color ='red')
sns.distplot(x, color ='blue')
plt.show()