Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Derek Goring

Posts: 3,919
Registered: 12/7/04
Re: Generate random numbers for a weighted uniform distribution
Posted: May 20, 2014 3:51 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.