How to generate matrix with mean equal to a specific number?
Mostra commenti meno recenti
How can I generate a random matrix A with
(for example A is 10x10) mean(A(:)) = 0.5 or says sum(sum(A)) / (10*10) = 0.5
Every element in matrix randomly from 0 to 1.
Thanks
Kai
2 Commenti
It is not possible to meet your conditions: If every element must be picked randomly between 0 and 1, it can be easily > 0.5, invalidating your condition that the sum must be equal to 0.5. Likewise, if the sum must be 0.5, the first element r(1) can be picked from [0, 0.5], the second element r(2) from [0, 0.5-sum(r)], and so on, until the final element which is not random at all but must be 0.5-sum(r), all invalidating your condition that the number must be randomly between 0 and 1. So what do you actually want to do?
Roger Stafford
il 10 Gen 2013
What you are saying, Thorsten, would only be true if one assumes that all number selections must be statistically mutually independent of one another, but Kai stated no such requirement. In the example I gave here of choosing three random variables, each between 0 and 1, whose sum is 3/2, the random variables can be so selected that the planar two-dimensional hexagon of number triples which satisfy all these conditions is uniformly distributed area-wise. It is my opinion that this satisfies Kai's requirements for randomness, but obviously the three random variables would not be mutually independent.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Random Number Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!