Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | File Exchange
ATOMS : Distfun details


Distribution functions
(1234 downloads for this version - 89681 downloads for all versions)
A more recent valid version with binaries for Scilab 5.4 exists: 0.9
Michael Baudin
Prateek Papriwal
Pierre Lecuyer
Luc Devroye
Jean-Philippe Chancelier
Michael A. Malcolm
Cleve B. Moler
George Marsaglia
Arif Zaman
Barry W. Brown
James Lovato
Kathy Russell
Makoto Matsumoto
Takuji Nishimura
Bruno Pincon
Owner Organization
INRIA, DIGITEO and others
Prateek Papriwal
Michael Baudin
Creation Date
December 1, 2012
Source created on
Scilab 5.4.x
Binaries available on
Scilab 5.4.x:
Windows 32-bit Windows 64-bit macOS
Install command
--> atomsInstall("distfun")
            Distribution Functions toolbox

The goal of this toolbox is to provide accurate distribution functions. 
The provided functions are designed to be compatible with Matlab.

The goals of this toolbox are the following.
 * All functions are tested with tables (actually, csv datasets).
   The tests includes accuracy tests, so that the accuracy 
   should by from 13 to 15 significant digits.
 * For each distribution, we have 
   * the probability distribution function (PDF)
   * the cumulated distribution function (CDF)
   * the inverse CDF
   * the random number generator
   * the statistics (mean and variance)
 * The CDF provides the upper and the lower tail of the 
   distribution, for accuracy reasons. 
 * The uniform random numbers are of high quality.
   The default is to use the Mersenne-Twister generator.   
 * Each function has a consistent help page.
   This removes confusions in the meaning 
   of the parameters and clarifies the differences 
   with other computing languages (e.g. R).
The design is similar to Matlab's distribution functions. 
A significant difference with Matlab's function is that both 
the upper and lower tails are available in "distfun", while 
Matlab only provides the lower tail. 
Hence, "distfun" should provide a better accuracy when 
probabilities close to 1 are computed (e.g. p=0.9999). 

There are many interesting, positive, differences with Scilab, Stixbox, or other
tools. For a full set of motivations, please read :

For each distribution x, we provide five functions :
 * distfun_xcdf — x CDF
 * distfun_xinv — x Inverse CDF
 * distfun_xpdf — x PDF
 * distfun_xrnd — x random numbers
 * distfun_xstat — x mean and variance

Distributions available :
 * Beta (with x=beta)
 * Binomial (with x=bino)
 * Chi-Square (with x=chi2)
 * Exponential (with x=exp)
 * F (with x=f)
 * Gamma (with x=gam)
 * Geometric (with x=geo)
 * Hypergeometric (with x=hyge)
 * LogNormal (with x=logn)
 * Normal (with x=norm)
 * Poisson (with x=poi)
 * T (with x=t)
 * Uniform (with x=unif)

 * dispfun_tutorial — A tutorial of the Distfun toolbox.
 * dispfun_plots — A collection of distribution function plots.

 * distfun_cov — Returns the empirical covariance matrix
 * distfun_erfcinv — Inverse erfc function
 * distfun_genericpdf — Compute the PDF from the CDF.
 * distfun_getpath — Returns path of current module
 * distfun_inthisto — Discrete histogram
 * distfun_plotintcdf -  Plots an integer CDF

Random Number Generator
 * rng_overview — An overview of the Random Number Generators of the Distfun
 * distfun_genget — Get the current random number generator
 * distfun_genset — Set the current random number generator
 * distfun_seedget — Get the current state of the current random number
 * distfun_seedset — Set the current state of the current random number
 * distfun_streamget — Get the current stream
 * distfun_streaminit — Initializes the current stream
 * distfun_streamset — Set the current stream            
Files (4)
[1.32 MB]
Source code archive

[1.56 MB]
Windows 32-bit binary for Scilab 5.4.x
Windows 32-bit
Automatically generated by the ATOMS compilation chain

[1.58 MB]
Windows 64-bit binary for Scilab 5.4.x
Windows 64-bit
Automatically generated by the ATOMS compilation chain

[1.18 MB]
macOS binary for Scilab 5.4.x
MacOSX version
Automatically generated by the ATOMS compilation chain

News (0)
Comments (4)
Comment from Michael Baudin -- December 1, 2012, 09:12:39 PM    
Here is the changelog for this version. 
This includes major changes and a large number of bug fixes.

distfun (0.5)
    * Added Binomial Distribution.
    * Added Poisson Distribution.
    * Added Chi-Square Distribution.
    * Added Hypergeometric Distribution.
    * Fixed two accuracy bugs in distfun_invcdfbin.
      The first bug happened for small values of S.
      The second bug happened for small values of Xn.
    * Fixed accuracy issue in distfun_geocdf when pr is small.
    * Fixed accuracy issue in distfun_expinv when p is small.
    * Fixed accuracy bug in distfun_expcdf when x is small.
    * Added a tutorial.
    * Added distfun_plotintcdf to plot discrete CDF.
      Updated the examples in all discrete CDF examples: 
      geometric, poisson, hypergeometric, binomial.
    * Checked that the x argument in distfun_betapdf is in [0,1].
      It is now consistent with the behavior of distfun_betacdf.
    * Fixed a typo in the example of distfun_binostat.
    * Fixed a typo in the example of distfun_geornd.
    * Fixed a bug in distfun_poissinv (arguments expansion).
    * Fixed distfun_hygernd to invert the CDF.
    * Fixed bug #870
      distfun_hygecdf was too slow
      Implemented with a C-based source code.
    * Fixed bug #778
      The Quick start of distfun was empty.
    * Fixed bug #874
      distfun_geoinv failed at p=1
    * Fixed bug #871
      distfun_hygeinv was too slow
      Implemented with a C-based source code.
    * Fixed bug #876
      The help page of distfun_hygepdf was wrong.
    * Fixed bug #882
      distfun_hygeinv was slow when M is large.
    * Fixed bug #875
      distfun_hygeinv produced a large value of x
    * Fixed distfun_hygepdf to make it compute zero 
      when x<N-M+k.
    * Fixed bug #883
      distfun_hygecdf was slow when M is large.
    * Fixed bug #889
      distfun_chi2cdf was not accurate in the upper tail
    * Fixed bug #881
      distfun_plotintcdf was too slow
    * Fixed bug #880
      distfun_exppdf did not check that x>=0.
    * Fixed bug #891
      distfun_hygeinv failed for p=1
    * Fixed bug #873: 
      The tests for cdf functions were obsolete.
      They now use the assert functions and tables of values.
    * Fixed bug #900
      distfun_binopdf was wrong for small pr and large N.
    * Fixed bug #918
      distfun_chi2pdf can produce a NaN.
      distfun_gampdf could also produce a NaN.
    * Fixed bug #913
      distfun_unifrnd could produce a zero
      Now all uniform generators are forced to generate 
      numbers in (0,1).
    * Fixed bug #912
      distfun_seedset did not accept vectors.
    * Fixed bug #897
      distfun_fpdf can produce a Nan
    * Fixed bug #831
      distfun_invcdpoi failed with small values of p
    * Fixed bug #926
      distfun_poissinv failed for p=1.
    * Fixed bug #779
      distfun_norminv failed when p = 1.
    * Fixed bug #777
      distfun_gaminv failed with p=1
    * Fixed bug #776
      distfun_expinv failed with p=1
    * Fixed bug #896
      invcdfbet produced weird result for extreme x
    * Fixed bug #932
      The urng gateway did not use the API.
    * Ported the tests on Scilab 5.4.0.
    * Created distfun_inthisto to plot integer histograms.
    * Fixed accuracy bug for the upper tail of distfun_poisscdf.
    * Added F Distribution.
    * Removed optional mu and sigma in Normal distribution:
      mu and sigma are now mandatory in 
      distfun_normpdf, distfun_normcdf, distfun_norminv.
      Backward compatibility lost.
    * Removed optional mu and sigma in Log-Normal distribution:
      mu and sigma are now mandatory in
      distfun_lognpdf, distfun_logncdf, distfun_logninv.
      Backward compatibility lost.
    * Fixed bug in distfun_binoinv, in the lower tail of the 
      distribution : call to floor is now replaced with a call to 
      ceil, which shifts the integers by +1.
    * Removed optional a and b in Uniform distribution:
      a and b are now mandatory in
      distfun_unifpdf, distfun_unifcdf, distfun_unifinv.
      Backward compatibility lost.
    * Added C-based implementation of the PDF of : 
      normal, chi-square, geometric, uniform.
    * Fixed bug #950.
      distfun_gaminv could go into an infinite loop.
    * Fixed bug #951.
      distfun_normcdf failed for x=+/-Inf.
    * Fixed bug #953.
      distfun_chi2inv fails for q=0.
      distfun_chi2inv fails for small p.
    * Fixed bug #958.
      distfun_binopdf could fail for non-integer input arguments.
    * Updated binomial distribution functions (distfun_binopdf, distfun_binocdf and 
      distfun_binoinv) to manage large values (greater than 2^32).
    * Fixed bug #960.
      distfun_poisspdf could fail for non-integer, extreme input arguments.
    * Fixed bug #962
      distfun_hygepdf failed for large inputs.
    * Updated hypergeometric distribution functions 
      (distfun_hygepdf, distfun_hygecdf and distfun_hygeinv) to 
      manage large values (greater than 2^32).
    * Updated distfun_poisspdf to manage large arguments.
    * Fixed bug #971
      distfun_betarnd failed for small inputs
    * Fixed bug #976
      distfun_frnd failed for extreme inputs
Comment from Michael Baudin -- December 16, 2012, 03:21:47 PM    
The Mac binaries are not available, as the compilation seems to fail. 
Comment from Michael Baudin -- December 17, 2012, 10:37:44 PM    
The Linux unit tests seem to produce too many failures (both in 32 and 64 bits): I disable

the download, until I can find a bugfix.
Comment from Michael Baudin -- January 11, 2013, 12:52:13 PM    
This release had bugs on Linux. This is fixed in the v0.6.