Results 1 to 2 of 2

Math Help - generating vector of random numbers in matlab until sum exceeds M

  1. #1
    Junior Member
    Joined
    Nov 2007
    Posts
    68

    generating vector of random numbers in matlab until sum exceeds M

    Given M and lamda by the user, i am trying to write matlab code that produces a vector of increasing size whose entries are exponentially distributed random variables (mean 1/lambda) until the sum of the vector exceeds M..

    any ideas how to do this?? I have been trying with while loops but cant quite do it...
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by johnbarkwith View Post
    Given M and lamda by the user, i am trying to write matlab code that produces a vector of increasing size whose entries are exponentially distributed random variables (mean 1/lambda) until the sum of the vector exceeds M..

    any ideas how to do this?? I have been trying with while loops but cant quite do it...
    Write a loop that calculates a single random number of the correct type, keep a running total when this exceeds M stop, otherwise append the new random number to the vector of those already found.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: June 3rd 2010, 09:39 AM
  2. Generating Random Variables
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: March 14th 2010, 05:49 PM
  3. Generating random variables
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: January 30th 2010, 11:41 PM
  4. MATLAB: Random numbers
    Posted in the Math Software Forum
    Replies: 3
    Last Post: January 28th 2009, 11:10 AM
  5. Replies: 3
    Last Post: October 20th 2005, 12:09 AM

Search Tags


/mathhelpforum @mathhelpforum