MATLAB Answers


How to generate a certain number of random numbers from a gamma distribution that sum to a specific number

Asked by John
on 21 Jun 2012


Would anybody know how to generate a specific number of random numbers from a Gamma Distribution that sum to a particular value?

I have (1) the total distance that one travels in a day and (2) the number of journey that they make.

For example:

Total Distance = 40 miles No. Journeys = 3

I'm trying to generate 3 random numbers from a Gamma distribution that sum to 40.

Appreciate any help with this

Thank you



Log in to comment.

1 Answer

Answer by Walter Roberson
on 21 Jun 2012

You could try adapting but the infinite tail might give some problems.

The result might not have the same gamma distribution as you started with.


Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!