From: ImageAnalyst on
Rajeev Narayanan:
I think you should be able to follow this very verbose example:


clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear all; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
randn('state', sum(clock));
p = zeros(1, 3^11);
T= 0.00000001
for k= 1:3^11
p(k) = sqrt(T)*randn;
end

% Get a scrambled list of all possible indexes.
numberOfElements = length(p);
allRandomizedIndexes = randperm(numberOfElements);

% Extract out 1000 of those.
% We can simply take the first 1000 since they're random.
numberOfElementsToExtract = 1000;
randomIndexesToUse =
allRandomizedIndexes(1:numberOfElementsToExtract);

% Extract the subsample with the proper number of elements from the
original array.
randomSubSample = p(randomIndexesToUse())
From: Jan Simon on
Dear Rajeev!

> randn('state', sum(clock));
> p = zeros(1, 3^11);
> T= 0.00000001
> for k= 1:3^11
> p(k) = sqrt(T)*randn
> end

Faster:
randn('state', sum(clock));
p = sqrt(0.00000001) * randn(1, 3^11);

Jan
From: Mark Shore on
"Rajeev Narayanan" <rite2rajeev(a)gmail.com> wrote in message <hoodr9$ro8$1(a)fred.mathworks.com>...
> Hello All,
>
> Thanks for all the information. The solution pick=randn(1,10000) will generate some 10000 random number, but i want to pick from the element p which i have already generated. I think i am confusing you people. Here is the code which i am using to generate p
>
> randn('state', sum(clock));
> p = zeros(1, 3^11);
> T= 0.00000001
> for k= 1:3^11
> p(k) = sqrt(T)*randn
> end
>
> Now from 'p' i need to pick some 10000 samples. Hope you understand the question.
>
> Thanks,
> Rajeev
>

The point others have been making that unless you are trying to evaluate MATLAB's pseudorandom number generator from its output (in which case your sample is far too small), there is no reason to select a subset of random numbers from a larger set. A randomized, scrambled or arbitrary selection of pseudorandom numbers won't be any more random than the distribution they have been selected from. So why bother?