-
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
-
-
×InformationFix Windows 10 Update Issues
Resolve Windows 10 related issues for your HP computers or printers by HP Windows 10 Support Center
-
- HP Community
- >
- Other Products
- >
- Calculators
- >
- Generation of a list of random numbers with specified limits
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Create an account on the HP Community to personalize your profile and ask a question

Solved!
Generation of a list of random numbers with specified limits
01-19-2017 05:44 PM - edited 01-19-2017 05:46 PM

Is it possible in the HP 50g to generate a list of random numbers, for example a list of 10 randoms numbers between 50.20 and 104.35?
thank you
Reynel
Solved! Go to Solution.
01-20-2017 12:07 AM - edited 01-20-2017 12:15 AM

@REYNEL wrote:Is it possible in the HP 50g to generate a list of random numbers, for example a list of 10 randoms numbers between 50.20 and 104.35?
thank you
Reynel
One way is by writing a little program like this:
<< 1 10 START RAND 54.15 * 50.2 + NEXT 10 ->LIST >>
Please note that the "->" above stands for the single right-arrow character.
Disclaimer: I don't work for HP. I'm just another happy HP calculator user.
01-20-2017 06:04 AM

Hi!, @REYNEL:
Welcome, in this new year HP Forum !.
You too, can use ...
L2. Randomize a List ‘RANL’ : In page 8 of 26 of One Minute Marvels, from ... http://www.hpcalc.org/details/1691
16 commands, 62.5 Bytes, #1F8Ch. Timing: 100 elements in 1.52_sec.
<< LIST→ → t << 1 t FOR n n RAND * CEIL ROLLD NEXT t →LIST >> >>
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
01-20-2017 08:30 AM

Joe_Horn,
Thank you very much! This approach worked very well.
01-20-2017 08:59 AM - edited 01-20-2017 04:05 PM

Hi!, @REYNEL:
Is very important what you know how work RANDOM, in HP 50G.
Random numbers :
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
01-20-2017 09:28 AM

@Maké wrote:
You too, can use ...
L2. Randomize a List ‘RANL’ : In page 8 of 26 of One Minute Marvels, from ... http://www.hpcalc.org/details/1691
16 commands, 62.5 Bytes, #1F8Ch. Timing: 100 elements in 1.52_sec.
<< LIST→ → t << 1 t FOR n n RAND * CEIL ROLLD NEXT t →LIST >> >>
Please note that the above program only shuffles an already-existing list. That is not what the original poster requested. However, I'm glad that Maké mentioned it, because studying the logic in this program (and all the programs in One Minute Marvels) is highly instructive, and can also be intellectually stimulating and entertaining.
01-20-2017 11:09 AM - edited 01-20-2017 04:33 PM

Hi!, @Joe:
If you are Engineer or Professor, then you must be know what needed, in each case, analyze and indicate the theory or syntax and this is more important what the example, for the user.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
01-20-2017 04:56 PM

Joe, your program worked like a charm. Thank you very much again!
However, the other answer that I got was confusing to me and I did not get the expected result. This time, I would like to apply the same problem as stated before, but instead of a list of 10 random numbers with the specified limits, I would like to to build a matrix with 3 columns and 10 rows filled with randoms numbers in the bound limits. That is between 50.20 and 104.35.
I was able to build this matrix by running your program 3 times and storing each run with a different variable and finally using the augmented matrix command to convert the 10 X 1 list into a 10X3 matrix. This is a painful task, since I have to repeated many times for a statistical project. Is it possible modify your original program and adapt it for a 10 by 3 matrix?
Thank you!
Reynel
01-20-2017 05:13 PM

@REYNEL wrote:Joe, your program worked like a charm. Thank you very much again!
However, the other answer that I got was confusing to me and I did not get the expected result. This time, I would like to apply the same problem as stated before, but instead of a list of 10 random numbers with the specified limits, I would like to to build a matrix with 3 columns and 10 rows filled with randoms numbers in the bound limits. That is between 50.20 and 104.35.
I was able to build this matrix by running your program 3 times and storing each run with a different variable and finally using the augmented matrix command to convert the 10 X 1 list into a 10X3 matrix. This is a painful task, since I have to repeated many times for a statistical project. Is it possible modify your original program and adapt it for a 10 by 3 matrix?
Thank you!
Reynel
The following little program will work, but it uses a slightly different approach than the previous program:
<< { 10 3 } 0 CON { 1 1 } DO RAND 54.15 * 50.2 + PUTI UNTIL -64 FS? END DROP >>
Change the initial list for other matrix dimensions. Change the two numbers in the middle of the program to adjust the random range and smallest number respectively. If you have any questions about how this works, just holler.
Didn't find what you were looking for? Ask the community