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)



Wow! I'm running the million sets of 21 quintets on a Lenovo with intel core 2, vpro, 3GHz in IPython. It takes about 5 minutes. I don't understand hours for this project.
Snip, snip


It's notable that Jeff's last run seemed to take 17 hours.(??) My runs are
taking about 2 hours - I think it's unlikely the variation has much to do with
the packages - likely it's hardware. I am running MATLAB on a refurb HP 6000
box I bought via Walmart for about $220 shown as an HP Compaq 6000 Pro
small form factor PC "core2 Intel Pentium" set up in 64 bit OS

Here's the current tabulation:

getdist3M(10)
totalrounds = 0 0 0 0 0 2 1
totalseq2 = 0 0 0 0 0 0 0
total = 0 0 0 0 0 0 0
Elapsed time is 0.009326 seconds.

getdist3M(100)
totalrounds = 0 0 0 2 4 3 9
totalseq2 = 0 0 0 0 0 0 4
total = 0 0 0 0 0 0 0
Elapsed time is 0.050846 seconds.

getdist3M(1000000)
totalrounds = 52 474 2739 9547 25806
52745 87119
totalseq2 = 0 19 135 730 2707
7744 17742
total = 0 0 0 14 162
1096 5401

Elapsed time is 6785.582071 seconds.

Brian Whatcott Altus OK


On 2/27/2014 9:52 AM, Jeffrey Schnick wrote:
-/snip/
On Feb 26, 2014, at 3:50 PM, Jeffrey Schnick<JSchnick@Anselm.Edu>
wrote:

Old Code:
getdist(1000000)
totalrounds = 49 482 2723 9827 25707 52175 86488
totalseq2 = 0 14 136 739 2712 7811 18039
total = 0 0 0 18 147 1063 5289

Here are the results with the new code:

octave-3.2.4.exe:13> getdist2(1000000)
totalrounds = 46 436 2662 9580 25606 52869 87332
totalseq2 = 2 17 143 787 2708 7775 18031
total = 0 0 1 9 161 1120 5359

Elapsed time is 14113 seconds.
-----------------
Here are results using randperm. (Code is below.)

octave-3.2.4.exe:46> getdist3(1000000)
totalrounds = 40 512 2824 9605 25362 52382 86908
totalseq2 = 1 12 174 786 2667 7612 17914
total = 0 0 1 9 142 1051 5341

Elapsed time is 60948 seconds.

Key:
Each result is 21 sets of 5 unique numbers between 1 and 35 inclusive.
totalrounds(1) = number of results with zero round numbers
(10,20,30)
totalrounds(2) = number of results with one round number.
totalrounds(i) = number of results with i-1 round numbers.

totalseq2(1) = number of results with zero sequences of two numbers
in a
row.
totalseq2(2) = number of results with one sequence of two numbers in
a
row.
totalseq2(i) = number of results with i-1 sequences of two numbers
in a
row.
total(1) = number of results with zero round numbers and zero
sequences
of two numbers in a row.
total(2) = number of results with one OR FEWER round numbers and one
OR FEWER sequences of two numbers in a row.
total(i) = number of results with i-1 OR FEWER round numbers and i-1
OR
FEWER sequences of two numbers in a row.
------------------------
function dummy = getdist3(n)
tic
for m=1:n
a=[ randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ...
randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ...
randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ...
randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ...
randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ...
randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ...
randperm(35)(1:5); randperm(35)(1:5); randperm(35)(1:5); ];
a=sort(a,2);
nrounds(m)=sum(10==a(:)) + sum(20==a(:)) + sum(30==a(:));
nseq2(m)=0;
for i=1:21
b=diff(a(i,:));
nseq2(m)=nseq2(m)+sum(1==b);
end
end


for i=0:6
totalrounds(i+1)=sum(i==nrounds);
end
totalrounds=totalrounds

for i=0:6
totalseq2(i+1)=sum(i==nseq2);
end
totalseq2=totalseq2

for i=0:6
total(i+1)= sum( nseq2<=i & nrounds<=i );
end
total=total

toc
_______________________________________________
Forum for Physics Educators
Phys-l@phys-l.org
http://www.phys-l.org/mailman/listinfo/phys-l


_______________________________________________
Forum for Physics Educators
Phys-l@phys-l.org
http://www.phys-l.org/mailman/listinfo/phys-l