Info
此问题已关闭。 请重新打开它进行编辑或回答。
How do I implement a random number distribution emulating an existing data stream?
2 次查看(过去 30 天)
显示 更早的评论
Hi, in the code displayed below I am trying to replace the generation of sequence1 and sequence2 by the generation of randomised sequences, for both 1 and 2 the random generation should be repeated 1000 times.
Some info about the data: The viewing time was recorded in ms for 30 participants in two conditions (Like_decision and Dislike_decision) with 40 trials for both.People looked at 2 pictures per trial and had to choose one, the other was labeled as non-choice Now I would like to create a pseudo-distribution made up of 1000*40 trials per condition. This I would like to compare with the distribution of my original data. I think I just have to change something in the first for loop. Any advice?
Matlab Code
% This program generates the time profile of the listening
% locked to the decision.
% Generate listening profile
Like_Decision = nan(20000,40,30);
Dislike_Decision = nan(20000,40,30);
for j=1:30
temp1 = dat(j).dat1;
temp2 = dat(j).dat2;
index1 = 0;
index2 = 0;
for i=[3:42 45:84],
overallTime = sum(temp2{i}(2:2:length(temp2{i})));
if overallTime > 300 && overallTime < 20000,
if temp1(i,4)==1
index1 = index1 + 1;
choice = temp1(i,6)-48;
Like_Decision(:,index1,j) = sequence1(temp2{i},choice);
else
index2 = index2 + 1;
choice = temp1(i,6)-48;
Dislike_Decision(:,index2,j) = sequence1(temp2{i},choice);
end
end
end
disp(['C1: ' num2str(index1) ', C2: ' num2str(index2)]);
end
end
function time = sequence1(rt,choice)
% This program will convert the rt sequence
% to a sequenece of 1s and 0s where
% 1 = choice
% 0 = non-choice
% Additionally we will also clip any rt to 20000 ms
time=[];
for i = 1:2:length(rt)-1
if rt(i) == choice
time = cat(1,time,ones(rt(i+1),1));
else
time = [time;zeros(rt(i+1),1)];
end
end
if length(time)>20000
time = time(end-20000+1:end);
else
time=cat(1,NaN(20000-length(time),1),time);
end
%time=downsample(time,5);
end
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!