Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.2 - English

Change language to:
Français - 日本語 - Português

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Statistics > cdfgam


cumulative distribution function gamma distribution

Calling Sequence




five real vectors of the same size.

P,Q (Q=1-P)

The integral from 0 to X of the gamma density. Input range: [0,1].


The upper limit of integration of the gamma density. Input range: [0, +infinity). Search range: [0,1E300]


The shape parameter of the gamma density. Input range: (0, +infinity). Search range: [1E-300,1E300]


The rate parameter of the gamma density. Input range: (0, +infinity). Search range: (1E-300,1E300]


Calculates any one parameter of the gamma distribution given values for the others.

The gamma density is

where a is the shape and r is the rate.

Caution. As opposed to other technical computing languages, this function makes use of the rate parameter, and not the scale parameter. The rate parameter is linked to the scale parameter with the equation rate=1/scale.

Computation of parameters such as X, Shape or Rate involve a seach for a value that produces the desired value of P. The search relies on the monotinicity of P with the other parameter.


In the following example, we compute the probability of the event x=0.1 for the Gamma distribution function with Shape=1.0 and Rate=1.0.

Shape = 0.1
Rate = 1.0
x = 0.1
// Expected : P = 0.8275518

In the following example, we compute the probability of the event x=0.1 and check that the search algorithms allows to consistently invert the function.

Shape = 0.1
Rate = 2.0
x = 0.3
[P,Q]    = cdfgam("PQ",x,Shape,Rate)
[X1]     = cdfgam("X",Shape,Rate,P,Q)
[Shape1] = cdfgam("Shape",Rate,P,Q,x)
[Rate1] = cdfgam("Rate",P,Q,x,Shape)

In the following example, we draw the Gamma distribution function for various values of the shape and rate.

N = 1000;
x = linspace(0,20,N)';
Shape = [1 2 3 5 9];
Rate = 1 ./ [2 2 2 1 0.5];
C = ["red" "green" "blue" "cyan" "orange"];
lstr = [];
h = gcf();
for i = 1 : 5
  P = cdfgam("PQ",x,Shape(i)*ones(N,1),Rate(i)*ones(N,1));
  lstr(i) = msprintf("Shape=%s, Rate=%s",string(Shape(i)),string(Rate(i)));
  h.children.children(1).children.foreground = color(C(i));
xtitle("CDF of the Gamma distribution function","X","P");


Cumulative distribution function (P) is calculated directly by the code associated with:

DiDinato, A. R. and Morris, A. H. Computation of the incomplete gamma function ratios and their inverse. ACM Trans. Math. Softw. 12 (1986), 377-393.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.

<< cdffnc Statistics cdfnbn >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu May 12 11:44:24 CEST 2011