The following warnings occurred:
Warning [2] Undefined array key 231616 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 231624 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 231651 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 231713 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 231713 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





Looking for PRNG for HP-34C



#3

I recently got a very pretty HP-34C from the usual place. It works very nicely; apparently the well-known tragic flaws of the series were avoided by previous owners. (I have flat-topped AA NiMHs on the way, which will be externally charged, yes yes.)

I immediately started programming it, with my usual first program, a simple dice roller. Alas, though this device is the ancestor of the HP-15C, and has many advanced features, it does not have a RAN# function. (I think the 11C and 15C were the first HPs to have that?) It also does not have the integer math which would allow a Linear Congruential Generator to be implemented; for instance, it lacks the modulo function.

So how can we make a good-enough PRNG? I looked through the program library here at the Museum for solutions for such machines as the HP-67. I found something in a game program, where the seed is retrieved from a storage register, muliplied by 997, the integer portion discarded, and the result stored again. I haven't done a lot of analysis but it doesn't appear to give very good results, though they are adequate in the game program.

So, can anybody devise a reasonably good floating-point-only PRNG? It should be suitable for at least the 34C. I hesitate to call this a 'challenge', since my solution is not actually mine, and I intend to replace it with whatever anybody comes up with that's better.

It should give a number >= 0, and less than 1. It should have results similar to rolling an unbiased 10^9-sided die, with as many digits as possible, and as long a period as possible, though if the only the first four or so digits are suitable that's OK. Naturally, it should use as few steps and registers as possible.

Thanks for considering...

Edited: 22 Sept 2012, 2:31 a.m.


#4

I remember using xn+1 = FRC ( 9821 xn + 0.211327 ) on all of my 41C*
See for yourself if these can fit your goal.
Greetings,
Massimo


Edited: 22 Sept 2012, 5:55 a.m.


#5

For the record: this pseudo random number generator was also mentioned in the 34C manual (or the standard applications manual). IIRC the source claimed it passed the spectral test by D. E. Knuth.

Since on a 34C this generator required eleven steps just for the two constants (or two registers, equivalent to 14 steps), I used to generate random numbers in a much simpler way: r := frac(r+pi)2. I have absolutely no idea if and how well this method passes any mathematical test, but it used to work fine for my purposes - i.e. programming games like "Mastermind". ;-)

Dieter


#6

Not very efficent but I used to use a vairation of the above on my HP33C and later my HP34C. I think it came from the HP97 manual but I can't be sure, hopefully I've remembered the seed correctly at that is an important bit!

001 LBL A
002 .
003 5
004 2
005 8
006 4
007 1
008 6
009 3
010 LBL 0
011 f PSE
012 9
013 9
014 7
015 x
016 g FRAC
017 GTO 0

It was a bit shorter on the HP33C as you didn't need to use labels which was just as well as there were only 49 program steps, so I usually entered the initial seed by hand before running the program.

Mike T.

Edited: 22 Sept 2012, 7:11 p.m.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP-34C Draining battery quickly Bill Crowell 2 1,338 09-08-2013, 08:30 AM
Last Post: aj04062
  HP-34C Curiosity Matt Agajanian 7 2,609 08-23-2013, 06:02 PM
Last Post: Stephan Matthys
  HP-34C Emulator BShoring 8 2,599 03-30-2013, 05:04 PM
Last Post: BShoring
  HP-34C Storage Register Arithmetic & Programming Matt Agajanian 14 4,013 05-08-2012, 11:04 AM
Last Post: Matt Agajanian
  A longstanding HP-34C mystery Matt Agajanian 11 3,394 05-03-2012, 02:29 AM
Last Post: Alexander Oestert
  HP 34C display problem james summers 11 3,825 04-05-2012, 06:07 PM
Last Post: james summers
  HP 34C and 67 for Android Vincent Weber 16 4,369 01-24-2012, 11:38 AM
Last Post: Alexander Oestert
  34C display problem Daniel CLEMENT 8 2,441 07-11-2011, 09:45 PM
Last Post: Michael de Estrada
  HP-34C Excitement Mark Henderson 9 2,416 05-21-2010, 04:33 PM
Last Post: Vieira, Luiz C. (Brazil)
  HP 34C - which way round are the batterys fitted? Jon Duke 6 2,112 03-30-2010, 11:39 AM
Last Post: Michael de Estrada

Forum Jump: