Chronology Current Month Current Thread Current Date
[Year List] [Month List (current year)] [Date Index] [Thread Index] [Thread Prev] [Thread Next] [Date Prev] [Date Next]

Re: [Phys-L] From a Math Prof (physics BS major) at my institution ( math challenge)



You are throwing out random numbers when you don’t “like” them. Specifically, you generate new random numbers whenever the numbers are too close together. Are you sure that’s random? Granted, it probably won’t break the Mersenne Twister generator used by Octave. But it is suspicious that you are discarding things which look very much like the pattern for which you are searching.

Wouldn’t it be better to do a:
for n=35:31

rn = fix(1+rand*n)

end

and then map those numbers onto the integers in the list?

Paul



On Feb 25, 2014, at 9:58 AM, Jeffrey Schnick <JSchnick@Anselm.Edu> wrote:

for m=1:n
a=zeros(21,5);
for i=1:21
a(i,1) = fix(1+rand*35);
for j = 2:5
rn = fix(1+rand*35);
while any(rn==a(i,1:j-1))
rn = fix(1+rand*35);
end
a(i,j)=rn;
end
end