Post Reply 
storing data in a list while executing a program
06-12-2017, 02:40 PM
Post: #1
storing data in a list while executing a program
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;
Find all posts by this user
Quote this message in a reply
06-13-2017, 05:02 AM
Post: #2
RE: storing data in a list while executing a program
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

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
06-13-2017, 07:55 AM
Post: #3
RE: storing data in a list while executing a program
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
Find all posts by this user
Quote this message in a reply
06-13-2017, 01:10 PM
Post: #4
RE: storing data in a list while executing a program
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.
Find all posts by this user
Quote this message in a reply
06-15-2017, 11:30 AM
Post: #5
RE: storing data in a list while executing a program
Many thanks for your advice Jan_D. When I get this finished I'll post the result.

best regards,
Pieter
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)