|
Bernoulli hit probability by given sum of probabilities +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (https://www.hpmuseum.org/forum/forum-10.html) +--- Forum: HP Prime Software Library (https://www.hpmuseum.org/forum/forum-15.html) +--- Thread: Bernoulli hit probability by given sum of probabilities (/thread-23611.html) |
Bernoulli hit probability by given sum of probabilities - peacecalc - 2025-05-25 Hello folks, by written such program for the HP 32SII, I tried to write such a program in HP-PPL for the prime. I use the prime G2 with the last beta version. The program solve the following equation: \[ \sum_{i=0}^{k} B(n,p,i) = w \] With given n, k, and w, the unknown variable is the hit probability p. In algebraic mode you have to input f. i. BERNOULLI_P(50,12,09373) = 0,16667. The good old HP 32SII needs for this 1 minute and 5 seconds. The Prime shows you the result immediatly (although the prim program corrected p until +/- 0,5^20 ~ 1E-6 the HP 32II only until +/- 0,5^14 ~ 6E-5). For great values n it is better to use the functions for the normal distribution. The program uses the program BINOMIAL_CDF, which it is a very astonishing funktion, because it is a very fast funktion. You get the results immediatly, even when n is large. Bernoulli_P.txt (Size: 502 bytes) RE: Bernoulli hit probability by given sum of probabilities - raprism - 2025-05-28 (2025-05-25, 15:09)peacecalc Wrote: Hello folks, As I don't (yet) write PPL programmes, but was interested in your program, I had the idea of writing it in Python. Thereafter it was only a little step to try this code also on HP Prime. So that's a Python version: Code: #PYTHON EXPORT BERNOULLI_P()Here is bit longer variant that can be called also on PC (using scipy): bernoulli_p.py (Size: 1490 bytes) |