Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Generate random numbers for a weighted uniform distribution
Replies: 3   Last Post: May 20, 2014 5:21 PM

 Messages: [ Previous | Next ]
 Derek Goring Posts: 3,922 Registered: 12/7/04
Re: Generate random numbers for a weighted uniform distribution
Posted: May 20, 2014 3:51 PM

On Wednesday, May 21, 2014 5:35:12 AM UTC+12, Anindya G wrote:
> Hello,
>
>
>
> I have been trying to generate random numbers for a "weighted uniform" probability distribution p(x) where
>
> p(x) = p0 for 0 <= x < a1,
>
> = p1 for a1 <= x <= a2,
>
> = ...
>
> = pn for an < x <= 1.
>
> Also, p1, p2, ... pn are chosen such that the integral(p(x)) = 1.
>
> So, in general, p(x) will have n probability weights for n intervals. The random number generator should take a vector of weights, and intervals to generate k (say) random numbers.
>
>
>
> I am wondering how can I use rand function to generate k random numbers for such a pdf. I understand that I can use rand function to generate random numbers for any pdf as explained in this post: http://www.mathworks.com/matlabcentral/newsreader/view_thread/173000
>
>
>
> But I am not clear how can I specify the integral expression in MATLAB for the weighted uniform distribution? Any help/hints will be greatly appreciated.
>
>
>
> Anindya.

help cumsum

Date Subject Author
5/20/14 Anindya G
5/20/14 Bruno Luong
5/20/14 Anindya G
5/20/14 Derek Goring