Little explorations with HP calculators (no Prime)
|
06-01-2017, 10:19 PM
(This post was last modified: 06-05-2017 01:54 PM by pier4r.)
Post: #222
|
|||
|
|||
RE: Little explorations with the HP calculators
but there are programs shared in the past with "@@" comments before newRPL was a thing.
And I learned the hard way that if I write: @ this is a comment containing an @ in the middle I get 'in' 'the' 'middle' on the stack. So either a string of consecutive "@" is stripped, or "@@" for me would mean "start a comment and stop it immediately". --- --- Aside from that, I am stuck in a relatively simple, although non standard, probabilistic problem because, well, I am still not good enough. Maybe someone here has an idea. So I know (or I think I know) the formula to compute the expected value given a probability density (discrete or not). I wanted to extend it to a new "dice". The new dice is given by the following procedure: I roll a dice 5 times in a row and I count the number of double ones that appears. That is , if I get the series 51161 I count 1, because there are only two ones appearing one after another. If I get 51116 , I count 2 double ones. 5[11]16 and 51[11]6. Of course something like 41356 has 0 double ones. So given a dice that returns those "results", I started to make a list of useful combinations: - 1 is were I expect a one - x is where I expect 2 to 6 - y is where I expect 1 to 6 , it is an isolated one. - only one double: 11xxy, 11xyx, x11xy, yx11x, yxx11, xyx11 probability for each series is 5*5*6/6^5 = 5^2/6^4 - two doubles: 111xy x111x yx111 probability 5*6/6^5 for the ones with y and 5^2/6^5 for the one with only x - two doubles: 11x11 prob 5/6^5 - three doubles: 1111x x1111 prob 5/6^5 - four doubles: 11111 prob: 1/6^5 expected amount of double ones: 6 * 1 * 5^2/6^4 + 2 * 2 * 5/6^4 + 2 * 5^2 / 6^5 + 2 * 5/6^5 + 2 * 3 * 5 / 6^5 + 4 * 1 / 6^5 = 0.14326 All the rest has 0 double ones, so it does not matter in the computation. Now, since I'm not sure, I also did a program to count for me (see below) but I got: 10 "rolls of this dice" produce an average of 0.1 100 produces 0.11 1000 produces 0.108 10000 produces 0.1092 So it does seem that either my code or my formula above is wrong and I would say my formula is wrong. Any ideas? edit: I ended up counting overlapping solutions. This guy helped, so my formula above is wrong when I count 11xxy and 11xyx (I count in one place 2-6 and then 1-6, therefore counting overlapping sequences) My code is right though. Power of computer science for the ones that performs poorly with math. Code:
---- update 2017 06 05 how to execute programs in other directories: http://www.hpmuseum.org/forum/thread-228...l#pid20222 Wikis are great, Contribute :) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)