From: Rajeev Narayanan on 28 Mar 2010 08:38 Hello, I have an array P=randn(1,x^y), where x and y are user input. I have x = 3 and y =15; From this i need to get some random sample of 10000. How can i do this? Thanks, Rajeev
From: us on 28 Mar 2010 08:51 "Rajeev Narayanan" <rite2rajeev(a)gmail.com> wrote in message <honijg$s1h$1(a)fred.mathworks.com>... > Hello, > > I have an array P=randn(1,x^y), where x and y are user input. I have x = 3 and y =15; From this i need to get some random sample of 10000. How can i do this? > > Thanks, > Rajeev a hint: help randn; % <- then, carefully look at the input args... us
From: John D'Errico on 28 Mar 2010 09:45 "Rajeev Narayanan" <rite2rajeev(a)gmail.com> wrote in message <honijg$s1h$1(a)fred.mathworks.com>... > Hello, > > I have an array P=randn(1,x^y), where x and y are user input. I have x = 3 and y =15; From this i need to get some random sample of 10000. How can i do this? Sigh. randn(1,3^15) So what is 3^15? >> 3^15 ans = 14348907 The call to randn has 14 million elements that it would return. Don't forget that they are doubles. This array would require 114791256 bytes of RAM to store. 114 megabytes of RAM. Now you want to generate 10000 samples of this size? Do you have 1.14 terabytes of RAM? I clearly don't have your budget for memory. Use a loop. Computer users have gotten spoiled. They think that their computers are infinitely fast and infinitely large. John
From: Jan Simon on 28 Mar 2010 10:30 Dear Rajeev! > I have an array P=randn(1,x^y), where x and y are user input. I have x = 3 and y =15; From this i need to get some random sample of 10000. How can i do this? Fortunately you use the function RANDN, which can operate on hyper-virtual memory: Imagine you have 3^15 random numbers. Than you can pick 10000 of them by letting RANDN pick *any* 10000 values: pick = randn(1, 10000); Kind regards, Jan
From: ImageAnalyst on 28 Mar 2010 10:51
Statistically, is that any different than just getting the 10,000 numbers directly and immediately via randomSample = randn(1,10000) ??? Either way you end up with 10000 normally distributed random numbers, right? |