! Illustrate Histogram feature of LINGO.  (CentralLimitTheorem.lng)
  Take a sample of NS observations, each
observation containing NU uniform random numbers.
Combine each set of size NU into a single number
using either sum, min, max, or product,
and plot the histogram using @CHARTHISTO( );
! Keywords:  Central limit theorem, Chart, ChartHisto, 
  Exponential distribution, Graph
  Histogram, LogNormal, Normal distribution;
SETS:
  OBS: RESULT;
  RV: DRAW;
ENDSETS
CALC: NS = 32000; ! Number observations; NU = 4; ! Number uniform random numbers in each obs.; UI = 0.43928; ! An initial random number seed; NBINS = 15; ! Optionally specify number bins; OBS = 1..NS; ! Declare set of observations; RV = 1..NU; ! Declare set of vars. per obs.; @FOR( OBS( i): @FOR( RV(j): UI = @RAND( UI); ! Get another uniform; DRAW(j) = UI; ); ! As NU gets large; RESULT(i) = @SUM( RV(j): DRAW( j)); !Converges to Normal; ! RESULT(I) = @MIN( RV(j): DRAW( j)); ! RESULT(I) = @PROD( RV(j): DRAW( j)); ! RESULT(I) = @MAX( RV(j): DRAW( j)); ); ! A histogram with NBINS bins; @CHARTHISTO( 'Sample Histogram', ! Title; 'Based on NU uniforms', ! X axis label; 'Frequency', ! Y axis label; 'Result', ! Label for data set plotted; NBINS, RESULT); ! If you choose NBINS = 0, then @CHARTHISTO will choose; ENDCALC