Reputation: 71
x = 10*rand(1,1e6);
n=100;
z = ((sum(x(1:n))-n*5)/std(x)*sqrt(n))*ones(1,1e6);
figure;
cdfplot(z)
So, for vector "z", I want every different numbers of 10,000 samples, when "x" is defined as sets of numbers between 0 to 10. However, if I implement my code, I can only get 10,000 same samples for "z". How can I create 10,000 different samples?
Upvotes: 0
Views: 116
Reputation: 8459
Your equation is the sum of x
minus 500, divided the the standard deviation of x
multiplied by 10, which will give a scalar which is then multiplied by a vector of ones. This will give you the same number repeated one million times.
Your question is very unclear so I am not sure what you want this code to do, however if you want to use 10,000 values between 0 and 10 to calculate each element of z
, and you are going to calculate one million random numbers in total, then I think this is what you want:
x=10*rand(1e4,100);
n=100;
z=(sum(x)-5*n)./std(x)*sqrt(n);
cdfplot(z)
Upvotes: 1