(25C) Sampling without repetition
|
10-28-2018, 09:18 AM
(This post was last modified: 10-28-2018 09:20 AM by Dieter.)
Post: #3
|
|||
|
|||
RE: (25C) Sampling without repetition
(10-27-2018 03:52 PM)Thomas Klemm Wrote: Here's a translation of your program for the HP-42S: One more case where something like INV DSZ would be useful (greetings to the TI community ;-)). This can be accomplished quite easily by having the DSE followed by a test that always tests false. Since X holds a positive number at this point, a simple x<0? will do. Code: ... Slightly shorter, slightly faster, saves one label. Edit: OK, in this special case it's neither shorter nor label-saving, simply because LBL 01 is required anyway. #-) (10-27-2018 03:52 PM)Thomas Klemm Wrote:(04-27-2017 04:07 AM)nsg Wrote: I wonder if it is possible to improve on the algorithm and generate a sample of modest k for arbitrary N, for example, a sample of 30 out of 10000000.In this case we might simply generate them at random and hope there's no collision. In such a case there is no significant difference between sampling with or without repetition. So it doesn't matter much if a number is drawn twice. Otherwise the idea is: record the sample in a (sorted) list, generate the next number, see if it's part of the list. If yes: get a new number, if not: insert it into the list. Hmmm... somehow this sounds like a job for the HP50. ;-) Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(25C) Sampling without repetition - nsg - 04-27-2017, 04:07 AM
(42S) Sampling without repetition - Thomas Klemm - 10-27-2018, 03:52 PM
RE: (25C) Sampling without repetition - Dieter - 10-28-2018 09:18 AM
RE: (25C) Sampling without repetition - John Keith - 10-28-2018, 08:03 PM
RE: (25C) Sampling without repetition - Albert Chan - 10-28-2018, 08:51 PM
RE: (25C) Sampling without repetition - Albert Chan - 10-28-2018, 02:18 PM
RE: (25C) Sampling without repetition - Thomas Klemm - 10-28-2018, 03:42 PM
|
User(s) browsing this thread: 1 Guest(s)