HP Forums

Full Version: storing data in a list while executing a program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to simulate waiting on a bus that arrives at an exact schedule(in this case every 10 minutes), 5 days a week you arrive at the busstop and you notice the time in minutes that you have to wait for the bus
If you do this 500 times , the program should export a list (L2) with estimations about the exact interval for the bus to arrive at the busstop.
Hypotest(5,500) should simulte 500 weeks of waiting 5 days a week for the bus.
There must be something wrong with this program, L2 is not generated correctly?
EXPORT HypoTest(N,T)
BEGIN
PRINT();
{}▶L2;
FOR D FROM 1 TO T DO
MAKELIST(RANDINT(9),X,1,N)▶L1;
L2(D):=approx(mean(L1)*2,2);
END;
PRINT(L2);
END;
Hello,

The program seems to work here, generating a list with N inputs...

Is there a reason for the *2 in mean(L1)*2 ?

In which way is L2 incorrect for you?

Cyrille
Hello Cyrille,

The program crashes on my up to date calcs, also on the emulator, please try N=5 and T=500, I see the output from: PRINT(L1) 'running' on my screen, this stops at different moments and the calc is crashed. Sometimes the program calculates all the iterations, then the data is afterwards available in L2. but I do never get the output from the second to last line in the program: PRINT(L2);

The reason I multiply by 2 is that we try to make an estimation about the bus schedule, one of the (more to follow) estimators is 2 times the average. The idea is to generate different estimators like; 2 times the mean, the max plus the minimum, the max value etc. by increasing the number of iterations we can investigate which estimator improves and how quickly it improves.

Thanks in advance for your advice!
Best regards, Pieter
It has not much to do with the program, but the list is too long in order to print.
When I create a simple list with length 500 and try to print it in Home view it does not succeed.

What's the problem when you can also see your data in the List catalog?

An alternative it to write your results to the Spreadsheet app,

E.g:

FOR D FROM 1 TO T DO
Spreadsheet.Cell(D,1):=L2(D);
END;

To make it even more user friendly you could add:

STARTAPP("Spreadsheet");
STARTVIEW(2,1); for viewing the Spreadsheet app,
or
STARTVIEW(-6,1); for viewing the List catalog.
Many thanks for your advice Jan_D. When I get this finished I'll post the result.

best regards,
Pieter
Reference URL's