Results 1 to 2 of 2

Math Help - Matlab Discrete Random Variable

  1. #1
    Junior Member
    Joined
    Sep 2010
    From
    Oslo
    Posts
    57
    Thanks
    4

    Matlab Discrete Random Variable

    Hi, I'm trying to simulate a discrete system that has a random input, but I can't figure out how to make the input signal.

    Basically, I want to create a vector whose entries are randomly selected from a list of possible values, each with an associated probability.

    Is there a simple way of doing this in Matlab?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Junior Member
    Joined
    Sep 2010
    From
    Oslo
    Posts
    57
    Thanks
    4

    Re: Matlab Discrete Random Variable

    Solved. I first made an n-length vector of random numbers between 0 and 1

    r=rand(1,n)

    and an indexing vector

    k=(1:1:n), where n is the desired number of samples.

    With p1, p2 etc. being the probabilities for each value of x, the signal becomes:

    x(k)=x1*(r(k)<p1)+x2*((r(k)>=p1)&(r(k)<p1+p2))+...

    This assigns each possible value of x a portion of the interval between 0 and 1 corresponding to its probability p. For each k an entry from r is checked by all terms. They all evaluate to zero except the one that contains the number from r.
    Last edited by TwoPlusTwo; September 30th 2012 at 04:31 PM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [SOLVED] Discrete Random Variable
    Posted in the Statistics Forum
    Replies: 6
    Last Post: February 22nd 2011, 06:13 PM
  2. PGF of Discrete Random Variable
    Posted in the Advanced Statistics Forum
    Replies: 3
    Last Post: March 12th 2010, 04:21 PM
  3. Replies: 3
    Last Post: January 13th 2010, 10:44 AM
  4. Discrete random variable help!
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: July 18th 2008, 11:10 PM
  5. discrete random variable
    Posted in the Advanced Statistics Forum
    Replies: 4
    Last Post: December 23rd 2007, 01:13 AM

Search Tags


/mathhelpforum @mathhelpforum