How to generate independent identically distributed random vectors of finite length using MATLAB?
|
|
0
|
|
|
|
Reply
|
Govindarajan
|
9/22/2010 4:11:19 AM |
|
"Govindarajan Jagannathan" <govind.ipr@gmail.com> wrote in message <i7bvl7$4id$1@fred.mathworks.com>...
> How to generate independent identically distributed random vectors of finite length using MATLAB?
The rand function produces uniformly distributed random numbers.
randn produces normally-distributed numbers.
Does that help?
Ross
|
|
0
|
|
|
|
Reply
|
Ross
|
9/22/2010 5:15:07 AM
|
|
"Govindarajan Jagannathan" <govind.ipr@gmail.com> wrote in message <i7bvl7$4id$1@fred.mathworks.com>...
> How to generate independent identically distributed random vectors of finite length using MATLAB?
Please define "finite length".
If you want a uniform distribution in the ball { x in R^d : |x| <= rmax }, then this should do:
d = 3; % dimension
rmax = 3; %
n = 1000; % number of vectors
v = randn(d,n);
r = (rand(1,n)*rmax^d).^(1/d);
c = r./sqrt(sum(v.^2,1));
v = bsxfun(@times, v, c);
Bruno
|
|
0
|
|
|
|
Reply
|
b.luong5955 (6337)
|
9/22/2010 5:27:04 AM
|
|
This might convince the above code works - at least in 2D:
d = 2; % dimension
rmax = 5;
n = 10000; % number of vectors
v = randn(d,n);
r = rmax * rand(1,n).^(1/d);
c = r./sqrt(sum(v.^2,1));
v = bsxfun(@times, v, c);
plot(v(1,:),v(2,:),'.')
axis equal
% Bruno
|
|
0
|
|
|
|
Reply
|
Bruno
|
9/22/2010 5:36:04 AM
|
|
Thank you very much for both the messages. I will try them out.
govind
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <i7c4k4$ods$1@fred.mathworks.com>...
> This might convince the above code works - at least in 2D:
>
> d = 2; % dimension
> rmax = 5;
> n = 10000; % number of vectors
>
> v = randn(d,n);
> r = rmax * rand(1,n).^(1/d);
> c = r./sqrt(sum(v.^2,1));
> v = bsxfun(@times, v, c);
>
> plot(v(1,:),v(2,:),'.')
> axis equal
>
> % Bruno
|
|
0
|
|
|
|
Reply
|
Govindarajan
|
9/22/2010 11:58:07 AM
|
|
Thank you for the information, Ross. It sure does help.
--govind
"Ross W" <rosswoodskiwi@hotmail.com> wrote in message <i7c3cr$7dd$1@fred.mathworks.com>...
> "Govindarajan Jagannathan" <govind.ipr@gmail.com> wrote in message <i7bvl7$4id$1@fred.mathworks.com>...
> > How to generate independent identically distributed random vectors of finite length using MATLAB?
>
> The rand function produces uniformly distributed random numbers.
> randn produces normally-distributed numbers.
>
> Does that help?
>
> Ross
|
|
0
|
|
|
|
Reply
|
Govindarajan
|
9/22/2010 12:00:20 PM
|
|
|
5 Replies
306 Views
(page loaded in 0.03 seconds)
Similiar Articles: Drawing n random numbers from vector without replacement - comp ...Drawing n random numbers from vector without replacement - comp ... How to generate random matrix with constraints? - comp.soft-sys ... Random vector generation - comp ... How to generate vector of random numbers in any interval (e.g. [-1 ...Random Price/Currency Value Generator - comp.lang.java.help ... How to generate vector of random numbers in any interval (e.g. [-1 ... Random Price/Currency Value ... Random map generation - comp.graphics.api.openglRandom map generation - comp.graphics.api.opengl How to generate a 2D intensity plot - comp.soft-sys.matlab ... Random vector generation - comp.soft-sys.matlab How to ... Generate random matrix with constraints - comp.soft-sys.matlab ...How to generate random matrix with constraints? - comp.soft-sys ... Random vector generation - comp.soft-sys.matlab Random vector generation ... How to generate random ... eye diagram in MATLAB - comp.soft-sys.matlabGenerate random matrix with constraints - comp.soft-sys.matlab ... > Easy: A=eye(5); A=A(:,randperm(5)) Bruno ... Random vector generation - comp.soft-sys.matlab Random ... How to set the seed as a 128 binary string of psudo random number ...Hi All, I'm doing a research, which requires to seed the pseudo random number generator with a 128 bit binary string (eg. 11001101) and obtain a vector of 1000 random ... random# histogram with gaussian overlay - comp.soft-sys.matlab ...Hi, I'm having problems with this: 1. Use the random # generator, randn, and an initial state of 0 to create a vector of 1000 normally distributed ... How to generate random number without replacement? - comp.lang ...random number generator from t location scale distribution - comp ..... numbers from vector without replacement - comp ... random number generator from t location scale ... random number generator from t location scale distribution - comp ...Drawing n random numbers from vector without replacement - comp ... random number generator from t location scale distribution - comp ... Drawing n random numbers from ... Random Price/Currency Value Generator - comp.lang.java.help ...Random Price/Currency Value Generator - comp.lang.java.help ..... numbers in any interval (e.g. [-1 ... If two values ... Random Number ... vector containing all ... scheme - random number generation inside a vector - Stack OverflowHello Under scheme I want to generate a vector of random numbers, I have tried this like this: (make-vector 10 (random 100)) and the output for this is such: random unit vector generator - File Exchange - MATLAB CentralFile exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community 7/24/2012 2:55:23 AM
|