Post Reply 
(25C) Sampling without repetition
10-27-2018, 03:52 PM
Post: #2
(42S) Sampling without repetition
Here's a translation of your program for the HP-42S:
Code:
00 { 41-Byte Prgm }
01▸LBL "SAMPLE"
02 RCL 00
03 STO 02
04 RCL 01
05 STO 03
06▸LBL 00
07 RCL 03
08 RCL 02
09 ÷
10 RAN
11 X≥Y?
12 GTO 01
13 RCL 02
14 STOP
15 DSE 03
16 GTO 01
17 GTO 02
18▸LBL 01
19 DSE 02
20 GTO 00
21▸LBL 02
22 -1
23 END

However, I reversed the order so I could use DSE.
Thus the generated samples appear in descending order.

Example:

100
STO 00
10
STO 01
XEQ "SAMPLE"
85
R/S
64
R/S
62
R/S
59
R/S
55
R/S
53
R/S
39
R/S
32
R/S
30
R/S
11
R/S
-1


(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.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


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



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