Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

random variable with varying mean

Status
Not open for further replies.

slam99

Computer
Nov 8, 2004
2
Hi,
I am just wondering if there is any quick way in Matlab to generate a random variable with a varying mean?
Thanks,
S
 
Replies continue below

Recommended for you

This makes no sense. A single number has a mean equal to itself. What is the distribution you are trying to fulfill?
 
Sorry, I meant a sequence of number. For instance, if I were to build a random sequence in matlab using the function "randn(1,N)", I would get an array of "N" number with mean=0. What I am after is the way to generate a sequence of number that don't have a fixed mean. Hopefully, this clarify the confusions result from my previous posting.
 
If the numbers are truly random, they're going to have a zero mean. You could take random numbers from a set, such as anything between -50 and 2,000, and the mean would be non-zero, but you can't randomize the mean. Trying to randomize the mean would ring you right back to a mean of zero (mean of a mean, if you will).
 
Just make a normal variable and set the mean to be yet another gaussian random variable. The speed that the mean changes is critical -- you want to filter the gaussian that represents the mean by doing a moving average or something. Change it at about 1/100 or so. You want to model a real process so the density you want is important.
 
When you say " to generate a sequence of number that don't have a fixed mean", do you have any particular function you want the mean to follow?

e.g.s :
increase linearly by some average value F(t) = a * t

oscillate around zero in a sinusoidal pattern F(t) = b * sin(at)

Once you determine how you want your mean to 'vary' it will be a lot easier to find a way to di it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor