# https://miptstats.github.io/courses/python/07_random.html import numpy as np from numpy import random import matplotlib.pyplot as plt scale= 4 size= 1_000_000 x= np.random.exponential(scale, size) plt.hist(x, bins=50, density=True) plt.show()
a random number on an exponential distribution
do you really mean several same-parametrized distributions? I suppose, from that x_distr (with params given above) you can make sample from size repeats in such a way:
from scipy.stats import rv_discrete random_state = 1234 Iterations= 2000 # ? - probably, just size of newly generated sample! https://mipt-stats.gitlab.io/courses/python/07_scipy_stats.html ##x = np.random.randn(100_000) unique, counts = np.unique(x, return_counts=True) print(unique, counts) # create object (use rv_continuous for continuous data) r = rv_discrete(name='some_distribution', values= (unique, counts/counts.sum()) ) #, size= Iterations) # make sample sample = r.rvs(size= Iterations, random_state= 123456) plt.hist(sample, bins= 20, density= True) plt.show()
P.S. or single exp distr can be taken also from scipy.stats:
from scipy.stats import expon lamb = 1 # The middle 80% of probability mass is located betweenthe 0.1 and 0.9 quantiles rv = expon(scale = 1 / lamb) q1 = rv.ppf(0.1) q2 = rv.ppf(0.9)