From: HollyandIvy He on 28 Jan 2010 12:38 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.
From: Steven Lord on 28 Jan 2010 12:44 "HollyandIvy He" <charon13y(a)googlemail.com> wrote in message news: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. You can do this using RAND, ./, and SUM. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: HollyandIvy He on 28 Jan 2010 13:02 RAND, ./, and SUM what's the meaning of './,' I can only think of p=sum(rand(6),1).,Obviously it can not work
From: Steven Lord on 28 Jan 2010 13:21 "HollyandIvy He" <charon13y(a)googlemail.com> wrote in message news:hjsjfj$cof$1(a)fred.mathworks.com... > RAND, ./, and SUM > > what's the meaning of './,' Type "help ./" (without the quotes) at the prompt and look for that symbol in the text that appears. I'm being a little cryptic, I know, but I suspect this is homework and if that's the case I think you'd get more of a benefit if you did it (mostly) on your own. > I can only think of p=sum(rand(6),1).,Obviously it can not work Actually, I thought of another way (that works because you didn't specify a distribution) -- generate a random 5 element vector and compute what the 6th element must be to make it sum to 1. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: HollyandIvy He on 28 Jan 2010 13:35 > > Actually, I thought of another way (that works because you didn't specify a > distribution) -- generate a random 5 element vector and compute what the 6th > element must be to make it sum to 1. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > What if the first 5 exceed 1, any value should be positive between [0,1] I have also thought about that before
|
Next
|
Last
Pages: 1 2 Prev: DMT model in Simulink Next: Callling libmx APIs from a standalone C++ program |