From: ImageAnalyst on 28 Jan 2010 14:40 Well you said they represent probabilities so I assume they'll all be between 0 and 1. Try this code: randomNumbers = rand(1,6) sumOfNumbers = sum(randomNumbers) normalizedRandomNumbers = randomNumbers / sumOfNumbers Regardless, this code will work no matter what the range of the numbers is. Now whether they're still "random" is a question for the mathematicians, since if you take any 5 of them, then the 6th one is determined (not random) since you're requiring that they all sum to 1, so perhaps it's not really random anymore.
From: Johnson on 3 Feb 2010 21:16 "HollyandIvy He" <charon13y(a)googlemail.com> wrote in message <hjsi1q$bjc$1(a)fred.mathworks.com>... > I don't know if this is possible. What I'm trying is to produce a row vector contain 6 random values presenting probability, thus the sum should be equal to 1. Scroll down to "Simplex Point Picking". I saw a MATLAB Central posting on this once but I think implementing the method on the wiki page below is pretty feasible. http://en.wikipedia.org/wiki/Simplex
First
|
Prev
|
Pages: 1 2 Prev: DMT model in Simulink Next: Callling libmx APIs from a standalone C++ program |