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


Distribution functions
(200 downloads for this version - 112417 downloads for all versions)
A more recent valid version with binaries for Scilab 5.3 exists: 0.4
Michael Baudin
Owner Organization
INRIA and others
Michael BAUDIN
Creation Date
May 16, 2012
Source created on
Scilab 5.3.x
Binaries available on
This toolbox is in the process of being built
            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=1 - 1.e-4). 

The differences with Scilab is that a consistent set of 
functions is provided. 
First, Scilab currently does not provide the PDFs. 
Users may write their own functions: this is not as easy as it 
seems, and may lead to very innaccurate results if floating point 
issues are ignored. 
Secondly, Scilab does not provide a consistent sets of functions: 
the CDF and the random number generators are provided in two 
different toolboxes, with no consistency. 

The difference with Stixbox is that the current function are 
tested, accurate, with consistent help pages.


 * distfun_betacdf — Beta CDF
 * distfun_betainv — Beta Inverse CDF
 * distfun_betapdf — Beta PDF
 * distfun_betarnd — Beta random numbers
 * distfun_betastat — Beta mean and variance
 * distfun_expcdf — Exponential CDF
 * distfun_expinv — Exponential Inverse CDF
 * distfun_exppdf — Exponential PDF
 * distfun_exprnd — Exponential random numbers
 * distfun_expstat — Exponential mean and variance
 * distfun_gamcdf — Gamma CDF
 * distfun_gaminv — Gamma Inverse CDF
 * distfun_gampdf — Gamma PDF
 * distfun_gamrnd — Gamma random numbers
 * distfun_gamstat — Gamma mean and variance
 * distfun_logncdf — Lognormal CDF
 * distfun_logninv — Lognormal Inverse CDF
 * distfun_lognpdf — Lognormal PDF
 * distfun_lognrnd — Lognormal random numbers
 * distfun_lognstat — LogNormal mean and variance
 * distfun_normcdf — Normal CDF
 * distfun_norminv — Normal Inverse CDF
 * distfun_normpdf — Normal PDF
 * distfun_normrnd — Normal random numbers
 * distfun_normstat — Normal mean and variance
 * distfun_unifcdf — Uniform CDF
 * distfun_unifinv — Uniform Inverse CDF
 * distfun_unifpdf — Uniform PDF
 * distfun_unifrnd — Uniform random numbers
 * distfun_unifstat — Uniform mean and variance

 * distfun_erfcinv — Inverse erfc function
 * distfun_getpath — Returns path of current module

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 substream
 * distfun_streamset — Set the current stream
Files (1)
[564.63 kB]
Source code archive

News (0)
Comments (1)     Leave a comment 
Comment from Michael BAUDIN -- May 16, 2012, 02:18:19 PM    
Here are the changes in the v0.3.

distfun (0.3)
    * Increased speed of rnd unit tests.
    * Removed the old grand function.
    * Connected distfun_cdf* functions instead of Scilab's cdf* 
    * Fixed bugs in src/c after f2c.
    * Added readme files src/c and sci_gateway/c to 
      clarify the architecture.
      Filled main readme.txt with purpose details.
    * Factored accuracy parameters of cdf* functions.
    * Fixed bug #9976 for the accuracy of cdfbet when x=0 on output.
    * Fixed accuracy bugs in Inverse beta CDF when p<1.e-50.
      Improved testing of inverse Beta CDF.
    * Simplified the cdf* functions (removed unused code).
    * Managed the empty matrix [] everywhere in distfun_cdf*.c and 
      distfun_invcdf*.c and macros distfun_*.sci
    * Refactored distfun_cdfpoi to remove the weird strings "PQ" and
      Created distfun_invcdfpoi for Inverse Poisson CDF.
      Updated distfun_cdfpoi: now only for Poisson CDF.
    * Same for distfun_cdfbet and distfun_invcdfbet for Poisson Distribution.
    * Same for distfun_cdfbin and distfun_invcdfbin for Binomial Distribution.
    * Same for distfun_cdfchi and distfun_invcdfchi for Chi-Square Distribution.
    * Same for distfun_cdfchn and distfun_invcdfchn for non-central Chi-Square 
    * Same for distfun_cdff and distfun_invcdff for F Distribution.
    * Same for distfun_cdft and distfun_invcdft for T Distribution.
    * Same for distfun_cdfgam and distfun_invcdfgam for Gamma Distribution.
    * Same for distfun_cdfnbn and distfun_invcdfnbn for Neg. Binomial Distribution.
    * Same for distfun_cdfnor and distfun_invcdfnor for Normal Distribution.
    * Same for distfun_cdffnc and distfun_invcdffnc for Non Central F Distribution.
   * Refactor the distfun_cdf* functions:
     Use Scilab's API
     Create a gw_support.c source and factor the Checkings in it.
   * Removed obsolete distfun_cdfbase.c from the sources.
   * Fixed license header in the unit tests.
   * Moved distfun_p2q into "internals" lib.
   * Added unit tests for distfun_grand* functions
     Fixed error messages for distfun_grand* functions
     Added distfun_grandlgi().
   * Changed random number generation from CDF inversion
     to direct generation.
   * Fixed messages format in distfun_grand* functions.
   * Fixed internal bugs in grand set/get functions.
     The current generator was not consistently managed.
   * Added missing distfun_grandexp.
   * Added missing distfun_grandpoi.
   * Connection distfun_grandprm.
   * Extended distfun_*rnd to manage empty matrices.
     Factored the common code into distfun_checkvmn().
   * Fixed a bug in distfun_checkvmn.
   * Added distfun_grandgeom
   * Fixed unit tests for distfun_grand* functions.
   * Extended distfun_grandunf to manage cases where a and b 
     are m-by-n matrices.
     Same for distfun_grandbet.
     Same for distfun_grandchi.
     Same for distfun_grandbin.
     Same for distfun_grandexp.
     Same for distfun_grandf.
     Same for distfun_grandgam.
     Same for distfun_grandgeom.
     Same for distfun_grandpoi.
     Same for distfun_granduin.
     Same for distfun_grandnf.
     Same for distfun_grandnbn.
     Same for distfun_grandnch.
   * Fixed a bug in distfun_exprnd, created after the 
     refactoring (this bug was not in v0.2)
   * Refactored distfun_grand(unf,bet,chi,bin) to share the 
     maximum possible amount of code.
   * Fixed distfun_cdfgam and distfun_invcdfgam to make sure 
     that Shape and Rate are > 0 (as done in distfun_grandgam).
   * Fixed a bug in the commends of distfun_grandgam.
     Fixed a bug in distfun_gamrnd (this bug was not present in v0.2).
   * Simplified the gateway support functions: removed unnecessary piaddr.
     Created distfun_GetSizedMatrixOfDoublesGreaterOrEqualThanZero and 
     distfun_GetSizedMatrixOfDoublesGreaterThanZero in distfun 
     to check sizes.
     Removed the size check from the src/gwsupport functions.
   * Split distfun_grandlaws.tst test into several distfun_grand* tests.
     Clarified unit tests of distfun_grand*.
   * Updated distfun_grandnbn to produce a warning when N has 
     not an integer value.
   * Updated distfun_grandbin to produce a warning when N has 
     not an integer value.
   * Updated distfun_exprnd to avoid to invert the CDF.
   * Updated distfun_lognrnd to avoid to invert the CDF.
   * Updated distfun_gamrnd to avoid to invert the CDF.
   * Updated distfun_normrnd to avoid to invert the CDF.
   * Separate the library in src/c :
     * the uniform random number generators functions -> src/unifrng
     * the non-uniform random number generators functions -> src/genrand
     * the CDF functions (i.e. DFDFLIB) -> src/cdflib
   * Updated rng for exp to make direct use of distfun_grandexp.
   * Added an option "lowertail" to distfun_*cdf functions to get q.
     Added to exp, gamma, logn, norm, unif, beta.
   * genrand : Updated to use a warning function.
   * clcg4 : Updated to use a warning function.
   * gwsupport : Created a proper warning function.
   * Clarified demos.
   * Removed distfun_grandlgi: unnecessary in practice.
   * Removed distfun_granddef: can be replaced with 
   * Remove distfun_grandphr2sd: unnecessary in practice.
   * Created a separate gateway for the uniform random number 
   * Renamed uniform-RNG specific functions into distfun_urng*.
   * Renamed clcg4 functions into distfun_clcg4*
     Removed unnecessary distfun_clcg4setall function:
     changed distfun_seedset so that the virtual generator G=0 
     is initialized and the others are initalized accordingly, 
     to get synchronization.
     There is no reason not to maintain the synchronization anyway.
   * Added help pages for distfun_genset, distfun_genget, 
     distfun_seedset and distfun_seedget.
   * Removed distfun_clcg4advnst: unnecessary in practice.
     Even worst: this can lead to wrong results.
   * Added help pages for distfun_clcg4get, distfun_clcg4set 
     and distfun_clcg4init.
   * Renamed functions to distfun_streamget, distfun_streamset 
     and distfun_streamnit.
   * Clarified the purpose of the virtual generators of clcg4.
   * Create a separate gateway directory for the configuration of 
     the uniform RNG.
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.