You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.GammaFit Function
Stats Master VCL
ContentsIndex
Example

The following example generates 100 random Gamma distributed values and then uses GammaFit routine to extract used a and b parameters:

Uses StatRandom, Statistics, MtxExpr;
procedure Example;
  var vec1: Vector;
  resA, resB : double;
  CIA,CIB: TTwoElmReal;
begin
    // first, generate 1000 randomly gamma distributed
    // numbers with parameters a=0.5 and b =1.2
    vec1.Size(1000);
    RandomGamma(0.5,1.2,vec1);
  // Now extract the a,b and their 95% confidence intervals.
    // Use at max 400 iterations and tolerance 0.0001
  GammaFit(vec1,resA,resB,CIA,CIB,400,1e-4);
end;
#include "StatRandom.hpp"
#include "MtxExpr.hpp"
#include "Statistics.hpp"
void __fastcall Example();
{
  sVector vec1;
    // first, generate 1000 randomly gamma distributed
    // numbers with parameters a=0.5 and b =1.2
    vec1.Size(1000,false);
    RandomGamma(0.5,1.2,vec1);
  // Now extract the a,b and their 95% confidence intervals.
    // Use at max 400 iterations and tolerance 0.0001
  double resA, ResB;
  TTwoElmReal CIA;
  TTwoElmReal CIB;
  GammaFit(vec1,resA,resB,CIA,CIB,400,1e-4,0.05);
}
Copyright (c) 1999-2025 by Dew Research. All rights reserved.