# Matlab - How to Generate Random Numbers from a Specific Probability Density

15 views (last 30 days)
Judith on 13 Apr 2012
Hi,
I'm trying to run a Monte Carlo type simulation. I have two different probability densities, one for the speed of the objects, Pv, and one for the angle, Pa. Both are given by complicated distributions that correspond to the physical system I am trying to model.
How would I go about generating random speeds and angles given these two distributions?
All of the rand based functions seem to pull random values from a set normalized distribution, which would not match my distribution...
Pv is a function of velocity,v, that goes as c(v^2)exp(-v/a)exp(-b/v) Pa is a function of angle, a, that goes as cos(a)
Any help would be greatly appreciated. I feel like I'm probably missing something pretty easy here.

Richard Willey on 13 Apr 2012
If Pv and Pa can both be described as functions of a, you might be able to use a univariate generator to generate plausible values for "a" using some known distribution and then derive Pv and Pa from this...
If this isn't feasible, you might be forced to cosnider something more complicated like a Markov Chain. The following url has a good introduction to Markov Chain Monte Carlo, along with MATLAB code.

### Categories

Find more on Stable Distribution in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by