(32S) Random Number Utilities - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (32S) Random Number Utilities (/thread-19011.html) |
(32S) Random Number Utilities - Eddie W. Shore - 10-23-2022 03:21 PM Note: The following programs should work with the original HP 32S. The checksums listed are for the HP 32SII only. HP 32SII Program: Fill a Set of Registers with Increasing Integers This program fills up the alpha registers with consecutive increasing integers. Up to 25 slots are available, A- Y, with the lowest being stored in A. Register Z is used to store the difference. The difference from both numbers should not be more than 24. Code: F01 LBL F F: 10.5 bytes, 32SII checksum 9FB9 I: 12.0 bytes, 32SII checksum E189 Total: 22.5 bytes Examples 18 to 27: 18 ENTER 27 XEQ F Results: A = 18, B = 19, C = 20, D = 21, E = 22, F = 23, G = 24, H = 25, I = 26, J = 27 HP 32SII Program: Pick from Registers A through Y Enter the number of registers to pick from into register Z. For example, if you have registers A through J loaded, store 10 into register Z. Note: When used for indirect addressing, the absolute value of integer of register i is used. This will allows us to save a few steps. Code: G01 RANDOM G: 12.0 bytes, 32SII checksum FE18 Example: Use the data from the last problem. 10 STO Z, XEQ G: 22 XEQ G: 21 (results will vary) Source for the next two programs: Chamberlain, Gary. "HP-29C Random Number Generators" PPC Journal V6 N7 October 1979 HP 32SII Program: Uniform Distribution This program picks random numbers between two parameters. Code: U01 LBL U U: 6.0 bytes, 32SII checksum 8022 W: 9.0 bytes, 32SII checksum 88EE Total: 15.0 bytes Example: Random numbers between -1 and 1: XEQ U: -0.74076 (press R/S for more random numbers) 0.28000 -0.80090 0.20653 0.50614 HP 32SII Program: Gaussian Distribution of Random Numbers Generate random numbers that fit on a normal distribution with mean M and deviation D. Two random numbers are generated, press x<>y to see both results. Code: X01 LBL X Example: Mean = 3 Deviation: 1.5 XEQ X M? 3 R/S D? 1.5 R/S 1.70434 x<>y 2.89313 R/S 2.22287 x<>y 2.50113 R/S 1.67644 x<>y 2.87034 ... (results will vary) |