using randn within an interval

Hey Does anyone know of a way to create an mxn matrix of random normals where each entry is within an particular bound. For example each entry is a random normal greater than -1 but less than 2. Thanks

 Accepted Answer

Walter Roberson
Walter Roberson on 27 Jun 2011
a priori bounded numbers never have normal distribution. normal distributions always have infinite tails in both directions.
When people ask this question, the common suggestion is to use a beta distribution instead.

3 Comments

Thanks for your answer Walter. Ya I saw a few people had suggested that when other people asked the same question, but I'm not actually concerned about it strictly being a normal distribution, only that it has an approximately bell curved shape. I want the user to be able to input a mean, variance for several series as well as a correlation structure between these series, and then produce several series, each with the inputted mean and variance and the correlation structure, but with each value being > -1. Is that possible? The basic idea is that I'm trying to simulate a stock market, with each series being a share and each entry being a return. The reason for the constraint is that a return obviously can't be less than -100%. If I haven't been specific enough just let me know and I'll try add a better explanation.
"approximately bell shaped curve" together with a lower bound and an infinite positive tail, sounds roughly like the shape of a poisson distribution to me.
Your proposal sounds a bit shaky to me, as it presumes price independence of different stocks, but that is seldom the case. Large scale forces affect large number of stocks, some in contrary directions to the forces (e.g., after a major hurricane, many stocks might go down, but disaster-cleanup stocks go up.)
I am, though, not an economist nor a statistician.
Ok I'll give the poisson a shot. No the other stocks are uncorrelated, they are randomly correlated, so that the user doesn't have to input these correlations. I did this because I'm only interested in the correlation between shares and the index, but yes, you're right, the other shares are correlated, which is why I put in the random correlation. Thanks for your help Walter!

Sign in to comment.

More Answers (1)

v1 = randn(m,n);
rndn12=1+(v1-min(v1(:)))/(max(v1(:))-min(v1(:)))
EDIT (06/27/2011 22:58 MSK)
itl = [-1 4]; % interval
v1 = randn(m,n);
rndn12=itl(1)+diff(itl)*(v1-min(v1(:)))/(max(v1(:))-min(v1(:)))

2 Comments

Ok thanks Andrei! The only thing is, is there a way to make the upside greater than the downside. What I mean is, to make it bounded on the range (-1,4) for example?
Hey man, sorry, ignore the fact that the other answer was accepted, I've never used this before and didn't know what I was doing, I am still stuck!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!