How to sample from truncated distributions using scipy? I have min and max values for certain variables such as:

*

*Expenses

*Loss

*Growth

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[0])


    #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)?

I don’t have permission to comment, so I’ll try to frame this as an answer.  If you really have truncated data —data that only takes values inside (and up to) the bounds, then @Sycorax’s answer applies.
However, if your data can take on wider values than your bounds in reality but are reported within the bounds — if high and low values are censored— then you’ll want to account for this by modeling spikes for the probability a number is less/greater than the bound.  Looks like built-in functionality is coming https://github.com/scipy/scipy/pull/13699, so until then, you may have to roll your own optimizer (discussed here https://stackoverflow.com/questions/64229245/mle-for-censored-distributions-of-the-exponential-family and surely many other places).
