Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
suyashi29
GitHub Repository: suyashi29/python-su
Path: blob/master/Generative AI for Intelligent Data Handling/ Day1 Probability Distribution Using NumPy .ipynb
3074 views
Kernel: Python 3 (ipykernel)
a=[1,2,3,4] type(a) a+a a*a a/a
[1, 2, 3, 4, 1, 2, 3, 4]
import numpy as np a1=np.array(a) a1*a1
array([ 1, 4, 9, 16])
a=[[1,2,3]] ,a=[[[]]]
import numpy as np import matplotlib.pyplot as plt # Generate random data from a normal distribution mu, sigma = 0, 0.1 # mean and standard deviation data = np.random.normal(mu, sigma, 1000) # Plot histogram of the generated data plt.hist(data, bins=30, density=True, alpha=0.5, color='g') plt.title('Normal Distribution') plt.xlabel('Value') plt.ylabel('Frequency') plt.show()
Image in a Jupyter notebook
# Generate random data from a uniform distribution low, high = -1, 1 data_uniform = np.random.uniform(low, high, 1000) # Plot histogram of the generated data plt.hist(data_uniform, bins=30, density=True, alpha=0.9, color='y') plt.title('Uniform Distribution') plt.xlabel('Value') plt.ylabel('Frequency') plt.show()
Image in a Jupyter notebook
Image in a Jupyter notebook
import numpy as np import matplotlib.pyplot as plt # Generate random data from an exponential distribution beta = 1/2 # scale parameter (inverse of the rate parameter) data_exponential = np.random.exponential(beta, 1000) # Plot histogram of the generated data plt.hist(data_exponential, bins=30, density=True, alpha=0.7, color='m') plt.title('Exponential Distribution') plt.xlabel('Value') plt.ylabel('Frequency') plt.show()
Image in a Jupyter notebook