Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

How do I implement a random number distribution emulating an existing data stream?

1 view (last 30 days)
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
  2 Comments
Doug Hull
Doug Hull on 2 Mar 2011
It is difficult to understand what you want. Can you show us what the sequences are that you are trying to emulate? Give their properties? The above code does not execute, so we are kind of lost.
Jenny
Jenny on 2 Mar 2011
I am trying to emulate the first two lines which is Like_Decision = NaN(20000,40,30) and Dislike_decision =NaN(20000,40,30).
The programme is getting the data from a matrix generated while conducting the experiment. Both the like and the dislike variable collected data from 30 participants in 40 trials each until 20000 milliseconds. The NaN means "Not applicable number" which the programme assigned to numbers exceeding 20000 milliseconds.
So both variables consist of a matrix containing both NaNs and numbers for 30 participants times 40 each.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!