Clear Filters
Clear Filters

How do I iterate a sample 1000 times?

3 views (last 30 days)
Ian Loveless
Ian Loveless on 20 May 2018
Edited: Stephen23 on 20 May 2018
I have simulated a sample of 1000 features where 100 are markers and 900 are non-markers. The variances for my samples come from an inverse wishart distribution with sigma=0.5 and kappa=3. I then used the variances generated as my variance to calculate a mean from a normal distribution with mean=0. From this, I generated the 1000 features from a normal distribution. I am using these samples to test different feature selection techniques and I am supposed to iterate each feature selection technique 1000 times. Is there a way of generating the 1000 sample sets simultaneously or do I need to generate each set one at a time?
Here is the code I am using to create my samples:
n0=50; %%%sample size in class 0
n1=50; %%sample size in class 1
x0=zeros(50,1000); %%%data in class 0
x1=zeros(50,1000); %%%data in class 1
%%%%first markers
for i=1:100
v0=iwishrnd(0.5,3);
v1=iwishrnd(0.5,3);
m0=normrnd(0,sqrt(v0/3));
m1=normrnd(0,sqrt(v1/3));
x0(:,i)=normrnd(m0,sqrt(v0),[n0 1]);
x1(:,i)=normrnd(m1,sqrt(v1),[n1 1]);
end
%%%now non-markers
for i=101:1000
v=iwishrnd(0.5,3);
m=normrnd(0,sqrt(v/3));
x0(:,i)=normrnd(m,sqrt(v),[n0 1]);
x1(:,i)=normrnd(m,sqrt(v),[n1 1]);
end
any help would be greatly appreciated.

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!