generating a random variable with a given mean and matrix
1 view (last 30 days)
Show older comments
fafz1203
on 15 Oct 2016
Commented: Diego Jaramillo
on 16 Apr 2020
can any one tell me how to generate a NORMAL DISTRIBUTION random variable X = N(mu,A), where mu is the mean (mu = 0, 0 mean) and A is a p*p IDENTITY MATRIX. Please ask me if the question is unclear. Thanks
Accepted Answer
Image Analyst
on 15 Oct 2016
Like this?
numRows = size(A, 1);
A(logical(eye(numRows))) = randn(1, numRows)
8 Comments
Image Analyst
on 15 Oct 2016
I don't believe you can do that and have the random variable be random. If it's random, you won't have A=eye(10) for the covariance matrix.
More Answers (0)
See Also
Categories
Find more on Random Number Generation 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!