R.PGAMMA Function (Gnumeric)
Calculate gamma cumulative and upper-tail probabilities with Gnumeric R.PGAMMA. Use shape and scale, log output and explicit boundary checks.
Verification status: 21 reference, boundary and advanced-check formulas were recalculated with Gnumeric 1.12.57 ssconvert. Saved identities, the blank input and numerical results were independently checked. Gnumeric 1.12.62 was source-checked only. How formula examples are checked
Quick answer: =R.PGAMMA(2,2,1) gives 0.59399415029 in Gnumeric 1.12.57.
Availability and version history
- Introduced: First release not established; present in the retained 1.12.57 source.
- Supported in: Gnumeric 1.12.62; no retirement is established.
- Scope: Desktop Gnumeric with its Statistical Functions From R plugin. English comma-separated formulas are shown.
- Checked: October 14, 2026. Tables and the named advanced check use 1.12.57 ssconvert. Current 1.12.62 source was inspected; that release was not executed.
What R.PGAMMA returns
R.PGAMMA returns a gamma cumulative probability, or the upper tail when lower_tail is FALSE. Shape and scale are required. A supplied rate λ must be converted to scale 1/λ; confusing the two produces a different distribution. Versioned function help.
Syntax and arguments
=R.PGAMMA(x,shape,scale[,lower_tail[,log_p]])
- x: cutoff; valid positive-shape models have cumulative zero at and below zero.
- shape, scale: required positive parameters. Scale has the same units as x.
- lower_tail: optional TRUE; FALSE selects P(X>x).
- log_p: optional FALSE; TRUE returns the natural logarithm of the selected probability.
Brackets mark optional arguments; do not type them. Current worksheet implementation.
Reproducible examples
These self-contained formulas were recalculated natively. Ordinary-domain results were checked against independent mathematics; invalid-model observations are identified separately below. Results are rounded to twelve decimal places, or thirteen significant digits for small nonzero values. This is presentation precision, not a universal accuracy guarantee.
| Formula | Gnumeric 1.12.57 result |
|---|---|
=R.PGAMMA(2,2,1) |
0.59399415029 |
=R.PGAMMA(4,2,2) |
0.59399415029 |
=R.PGAMMA(1,1,2) |
0.393469340287 |
=R.PGAMMA(3,3,1) |
0.576809918873 |
=R.PGAMMA(2,2,1,FALSE()) |
0.40600584971 |
=R.PGAMMA(2,2,1,TRUE(),TRUE()) |
-0.520885807664 |
=R.PGAMMA(2,2,1,FALSE(),TRUE()) |
-0.901387711332 |
=R.PGAMMA(0,2,1) |
0 |
Practical worksheet
For shape=2, scale=1 and x=2, the cumulative probability is approximately 0.593994150290 and the upper tail is 0.406005849710. The same cumulative probability occurs at x=4 with scale=2 because x/scale is unchanged.
For integer shape 2, the upper tail is EXP(-x/scale)*(1+x/scale). At x/scale=2 it is 3×EXP(−2), giving a useful independent calculation.
Advanced interpretation and checks
The cumulative probability is the regularized incomplete gamma integral up to x/scale. The scale invariance in the advanced check compares R.PGAMMA(4,2,2) with R.PGAMMA(2,2,1). It concerns cumulative probability; density values also require a reciprocal scale factor.
For a small upper-tail event, use FALSE directly and request log_p=TRUE when a logarithm is needed. In the example, log upper-tail probability is approximately −0.901387711332. A log probability is normally negative and is not a negative ordinary probability.
The saved advanced-check result for =R.PGAMMA(4,2,2)-R.PGAMMA(2,2,1) was 0.
Boundaries and troubleshooting
Negative shape and nonpositive scale produced #NUM!. Shape=0 is an implementation limit case: x=0 returned cumulative 0, whereas positive x returned 1. Use shape>0 for the ordinary continuous gamma interpretation.
For valid shapes, x=0 has lower-tail probability 0 and upper-tail probability 1. Their log results are therefore #NUM! and 0 respectively. F5 is a blank cutoff and follows x=0. Incorrect argument counts and nonnumeric text are separate errors.
F5 is genuinely empty, rather than a cell containing an empty string. #NUM! can represent an unrepresentable infinite mathematical endpoint as well as an invalid numeric domain; the distinctions above matter.
| Formula | Gnumeric 1.12.57 result |
|---|---|
=R.PGAMMA(-1,2,1) |
0 |
=R.PGAMMA(1,0,1) |
1 |
=R.PGAMMA(0,0,1) |
0 |
=R.PGAMMA(1,-1,1) |
#NUM! |
=R.PGAMMA(1,2,0) |
#NUM! |
=R.PGAMMA(1,2,-1) |
#NUM! |
=R.PGAMMA(0,2,1,TRUE(),TRUE()) |
#NUM! |
=R.PGAMMA(0,2,1,FALSE(),TRUE()) |
0 |
=R.PGAMMA("abc",2,1) |
#VALUE! |
=R.PGAMMA(F5,2,1) |
0 |
=R.PGAMMA(1,2) |
#N/A |
=R.PGAMMA(1,2,1,1,0,1) |
#N/A |
Official evidence and checking scope
- Current worksheet callback
- Tested-version worksheet callback
- Current pgamma calculation
- Tested-version pgamma calculation
- Nonfinite worksheet-value handling
- Statistical Functions From R plugin declaration
The relevant complete worksheet callback and main calculation helper are unchanged between the inspected versions. That does not establish later-version numerical execution. Both stale and uncached SUM controls recalculated correctly. Native XML identities were checked; secondary ODF exports retain these functions with the ORG.GNUMERIC namespace. GUI entry, other locales and other spreadsheet products were not tested.