I need help creating a loop for an experiment
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Stephen Huckins
am 5 Okt. 2021
Kommentiert: David Hill
am 9 Okt. 2021
I am fairly new to MATLAB and I am having trouble conceptualizing this code. I have an experiment with 25 subjects, where we will be collecting two videos each day for each subject (for 21 days), and will need to randomely select these videos for review over 28 days from this growing pool. I will have to edit some videos, and I need a way to randomely select the videos so that they are not viewed on consecutive days, and not to be viewed more than 3 or 4 times. This is so that videos are not all reviewed early on in the experiment.In other words:
Day 1 - Record 2 events
Day 2 - Record 2 events...
Day 21 - Record two events
The review of the videos is as follows:
Day 2 - Review 1 videos
Day 3- Review 2 videos
Day 4- Review 3 videos
Day 5- Review 4 videos
Days 6- Review 5 videos...
Day 28- Review 5 videos
To reiterate, there will be 42 videos to be recorded, and 125 reviews (1/3 review conditions will be baseline/no review), and I cant have the videos reviewed on consecutive days, or more than 3 or 4 times.
Would it be something like:
videoPool=1:42
subi=1:25
day=1:28
randSel=randi(videopool,1,1)
if videoPool ==
randi(videopool,1,1)
else
or
A=[1 2 ;1 2]
sz=size(A);
x=randi(42,sz)
This is where I am getting lost
4 Kommentare
Walter Roberson
am 5 Okt. 2021
125/28 was reviews per day. 125/42 is average reviews per video.
I see you added schedule information. I will think about it more but have something else to do at the moment.
Akzeptierte Antwort
David Hill
am 7 Okt. 2021
Bearbeitet: David Hill
am 7 Okt. 2021
Number the videos produced each day starting at 1 and going to 1050 (21 days, 50 videos each day).
videoPool=[];
K=[1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];%reviews per day for each of 25 people
h=[];
for k=1:27
videoPool=[videoPool,(k-1)*50+1:k*50];%50 new videos each day added to pool
s=randperm(numel(videoPool),K(k)*25);%select videos to review
DayReview{k}=reshape(videoPool(s),[],25);%each column is the video each person will review
h=[h,DayReview{k}(:)'];
f=find(histc(h,1:max(videoPool))==4);
h(ismember(h,f))=[];%once reviewed 4-times delete from history and videoPool
videoPool(ismember(videoPool,f))=[];%delete 4-time reviewed videos from pool
end
6 Kommentare
David Hill
am 8 Okt. 2021
This should prevent consecutive video reviews.
K=[1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];%reviews per day for each of 25 people
for participant=1:25
videoPool=[];
h=[];
Removed=[];
for k=1:27
if k<=21
videoPool=[videoPool,(k-1)*2+1:k*2];%2 new videos each day added to pool for the first 21 days
end
i=max(K(k)+1,floor(numel(videoPool)/2));%for skewing selection to upper half
d=numel(videoPool)-i;
if d~=0
s=[randperm(i,floor(.8*K(k)))+d,randperm(d,ceil(.2*K(k)))];%select videos to review
else
s=randperm(i,K(k));
end
DayReview{participant,k}=videoPool(s);
h=[h,DayReview{k}];
f=find(histc(h,1:max(videoPool))==4);%change to 3 if you only want maximum 3-times by all participants
h(ismember(h,f))=[];%once reviewed 4-times delete from history and videoPool
videoPool(ismember(videoPool,f))=[];%delete 4-time reviewed videos from pool
tempRemove=DayReview{k}(~ismember(DayReview{k},f));
videoPool(ismember(videoPool,DayReview{k}))=[];
videoPool=[videoPool,Removed];
Removed=tempRemove;
end
end
David Hill
am 9 Okt. 2021
I don't think you are reading the matrix properly. Each row is a person. As you move through the columns you are moving to the next day. There are no videos being reviewed on consecutive days for the same person. Video 2 for person 1 and person 2 are different videos (each person makes different videos as your previous said).
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!