I have min and max values for certain variables such as:
I'd like to add a distribution around them and plot a histogram in python. Distribution could be beta, gamma right type as these variables tend to follow.
Based on the documentation for sampling from different distribution types, I need to define mean and sigma.
My function calculates the mean of two numbers which define the range, and sample from a different distribution types.
def draw_samples(min, max): avg = (min + max)/2 print(avg) arr =  for i in range(200): # Simulate rent growth % r = np.random.disttype(avg, .2, size=1) arr.append(r) #print("List of values", arr) print("Mean value", np.mean(arr)) plt.hist(arr, density=True, bins=30) # density=False would make counts plt.ylabel('Probability') plt.xlabel('Data') # Call function draw_samples(1,6)
The range is values on the x-axis is not within the defined range (1,6). How are values sampled being defined?
Basically, I'd like to randomly sample n times but follow a certain distribution type and then compute the average value.
Say, growth variable can take values anywhere from -2 to 4% but with a non uniform distribution like gamma right, small chance it is <0. So then, how do I add a truncated distribution and sample from it?
Another way of doing this could be to sample n times using
r = np.random.disttype(mu, .2, size=n)?