Truncating a normal/Gaussian distribution
Show older comments
Hi, I'm trying to create an mxn matrix of normal random variables such that the mean for each column is 2, variance for each column can be specified (for example variance of column 1 is 4, column 2 is 3 etc). Also, I want to be able to specify the correlation between each column. However, each entry needs to be truncated so that it can't be less than -1. Could anyone help me? Thank you!
Answers (1)
David Young
on 28 Jun 2011
You can do truncation like this:
truncated = max(original, -1);
but note that your results will not be from a normal distribution any more.
Another way to ensure the values are all -1 or greater would be to replace the bad ones with a new random sample, repeating until all the values are ok. Whatever method you use, the results will not be from a normal distribution.
For setting the mean and variance, see Example 1 in the documentation for randn. Whether this is sufficient depends on whether you want to set the mean and variance before or after the truncation.
For setting the cross-correlations, I guess that one applies a matrix transform to a matrix of independently-generated values - you should be able to find a reference to this.
Categories
Find more on Correlation and Convolution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!