(HP 41) (DM 41X) Stratified Random Sampling
|
10-10-2020, 12:30 PM
Post: #1
|
|||
|
|||
(HP 41) (DM 41X) Stratified Random Sampling
Hi,
This is my first program for the HP 41 since decades. So it may be that there are numerous ways to improve the code. I have tested it on a DM 41X and a HP 41CL. What it does: The program helps to analyze stratified random samples. You can either put in the weights (i.e. the shares of the strata in universe) and the standard deviations within the strata or you can put in a density function and the weights of the strata and the standard deviations within the strata are computed. For the allocation of the sample on the strata you can put in numbers or let the program compute sample sizes for proportional or optimal allocation. Standard deviation of total mean is computed. Needs command “INTEG” from Advantage Module. Use of registers: 00 Final result 01 Name of density function global label (Alpha) 02 Number of strata (maximum: 6) 03 Sample size 04 Lower limit of first stratum Stratum 1 2 3 4 5 6 Upper limit 05 06 07 08 09 10 Weights 11 12 13 14 15 16 Std. dev. 17 18 19 20 21 22 Register 23-30 are used for computations. Program INTEG from ADVANTAGE module needs another 32 unused program registers. Usage instructions: See program listing Example: You want to analyze a stratified sample with 4 strata and optimum allocation of sample. The variable has a standard normal distribution. Strata limits are -1, 0, 1. Total sample size is n=1000. For convenience you take as lower limit of standard normal distribution -7.5 and as upper limit 7.5. First type in routine for normal distribution under global label: 01 LBL “NV” 02 x² 03 2 04 / 05 CHS 06 e^x 07 2 08 PI 09 * 10 SQRT 11 / 12 RTN XEQ “STRAT” -> SMPL SZ? – 1000 R/S (sample size input) -> N STRATA? – 4 R/S (input of number of strata) -> 0=I 1=DF? – 1 R/S (we use densitiy function, so we type 1) -> NM DF? – NV R/S (input of label of program with density function) -> LL S1? – 7.5 CHS R/S (lower limit of first stratum is -7.5) -> UL S1? – 1 CHS R/S (upper limit of first stratum is -1) -> UL S2? – 0 R/S -> UL S3? – 1 R/S -> UL S4? – 7.5 R/S After about 15 minutes (HP 41) / 20 seconds (DM 41X with power supply): -> 0=I 1=P 2=O? – 2 R/S (we want optimum allocation, so we type 2) -> N1=212 (sample size in stratum 1) R/S -> N2 = 288 (sample size in stratum 2) R/S -> N3 = 288 R/S -> N$ = 212 R/S -> 0.0106 (std deviation of stratified sample mean) Weights and standard deviations can be seen in registers, e.g. weight in stratum 1: RCL 11 -> 0.1587 Code: 01 LBL STRAT |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)