Contact

RANDNEGBINOM Function (Gnumeric)

Statistical Intermediate Gnumeric

Simulate failures before a target number of successes with Gnumeric RANDNEGBINOM, clarifying its help-text parameter mismatch.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

RANDNEGBINOM generates a nonnegative integer from a negative-binomial distribution. A crucial Gnumeric documentation detail is that the worksheet help labels its second argument “number of failures,” while the actual 1.12.57 generator passes it as the size parameter to the negative-binomial quantile routine. For the integer parameters used here, the implementation counts failures before the specified number of successes.

Syntax and the implemented convention

RANDNEGBINOM(p, n)

p is the probability of success per independent trial. n is the target number of successes under the implemented convention. Use 0 < p <= 1 and a positive integer n. The callback rejects p below zero or above one and n below one, then floors n before calling the generator.

The source chain is explicit: the worksheet callback calls random_negbinom with the floored second argument; that helper calls qnbinom, whose associated distribution implementation defines failures before the nth success. Thus the random result is not the total number of trials. Add n if the model needs total trials.

Although the worksheet’s initial guard admits p=0, this guide excludes it: achieving a positive number of successes is not a finite waiting-time experiment when success probability is zero. No native p=0 test or finite-output promise is made.

Worked example: successes and failed attempts

For independent attempts with success probability 0.5, =RANDNEGBINOM(0.5,5) returns one simulated count of failures before five successes. The result is an integer at least zero; it is not guaranteed to equal 5. The retained native run returned 7 failures, corresponding to 12 attempts in that particular run.

Put that formula in A2 and =A2+5 in B2 to represent total attempts in the same simulated run. If the saved value in A2 is 3, B2 is 8. That conditional arithmetic example does not claim that a particular native run returned 3.

The boundary =RANDNEGBINOM(1,5) returns 0: every attempt succeeds, so five successes require no failures. The independently known mean failure count for this convention is n*(1-p)/p, which is 5 when p=0.5 and n=5. That mean is a long-run property, not the expected literal output of each worksheet cell.

Advanced use: simulate a waiting-time workload

Keep p and n in clearly labeled assumption cells. Generate one failure count per row and derive total attempts from that same row’s result. If each attempt has a fixed duration, multiply the total-attempt count by that duration in a separate column. Distinguish the duration per attempt from any extra cost applied only to failures.

Before interpreting averages, ensure the model’s assumptions fit the situation: fixed success probability and independent attempts are substantial assumptions. A process whose success probability changes after a failure is not automatically described by this formula. The bounded native checks establish dispatch and selected outputs, not the suitability of a business or reliability model.

Errors and troubleshooting

=RANDNEGBINOM(-0.1,5) and =RANDNEGBINOM(0.5,0) return #NUM! in the selected contract. Use an integer n rather than relying on flooring of fractional inputs. The function is volatile; repeated recalculation can change the count, and using two calls for “failures” and “total attempts” creates different simulations.

If another source says n is failures, resolve the parameter convention before comparing results. The help-label discrepancy is disclosed here rather than silently copying it. Preserve the version when sharing this workbook with another application.

Version and verification

Official release notes add RANDNEGBINOM in Gnumeric 0.49. The implemented convention is traced through official 1.12.57 worksheet, generator, and mathematical source. The selected examples were recalculated by the actual Gnumeric 1.12.57 engine under C.UTF-8 on 17 October 2026. No p=0 test, GUI screenshot, distribution-quality certification, or retirement claim is made.

Official references