home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / NONLIN.ZIP / SIMPLEX.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1985-12-28  |  21.3 KB  |  709 lines

  1. program simp;   {curve fitting with the simplex algorithm}
  2. const
  3.  
  4. {********************************************************************}
  5. {THESE PARAMETERS MUST BE CHANGED FOR EACH DIFFERENT MODEL TO BE FIT}
  6.      m=2;                    {number of parameters to fit}
  7.      n=3;                    {n=m+1}
  8.      nvpp=3;                 {total # of vars per data point}
  9. {*********************************************************************}
  10.  
  11.         variance = false;       { bootstrap ?}
  12.         debug = false;
  13.         mnp=900;                {maximum # of points -- depends on memory available}
  14.         no_simplex=100;         {number of times bootstrap performed}
  15.         alfa=1.0;               {reflection coefficient, > 0}
  16.         beta= 0.5;              {contraction coeff, 0 to 1 }
  17.         gamma = 2.0;            {expansion coeff, > 1}
  18.         lw = 5;                 {width of line in data fields +1}
  19.         page=12;
  20.         root2=1.414214;
  21.  
  22. type
  23.         vector=array [1..n] of real;
  24.         datarow=array [1..nvpp] of real;
  25.         index=0..mnp;
  26.         input = array[1..mnp] of datarow;
  27.  
  28. var
  29.         residual,plots: boolean;        {flags for output files and plots}
  30.         ok,done:boolean;                {flag for simplex}
  31.         i,j:index;
  32.         h,l:array[1..n] of index;       {number high/low paramts}
  33.         np,                             {number of records read}
  34.         maxiter,                        {max # iterations}
  35.         niter:integer;                  {# of iterations}
  36.         next,                           {new vertex to be tested}
  37.         center,                         {center of hyperplane described
  38.                         by all vertexes of the simplex excluding the worst}
  39.         mean, error,
  40.         maxerr,                         {maximum error accepted}
  41.         p,q,                            {to compute the first simplex}
  42.         step :vector;                   {input starting steps}
  43.         simp:array[1..n] of vector;     {the simplex}
  44.         data1,data: input;              {the data}
  45.         fname: string[14];              {input file name}
  46.         nerr,nfit:string[14];           {file names for fitted and residual files}
  47.         ferr,ffit,din,
  48.         dout,fin,fout: text;            {file variables}
  49.         printer: boolean;               {printer flag}
  50.         response:char;
  51.         title:string[80];               {for title}
  52.         position:integer;               {new position from 'sample' used in bootstrap}
  53.         stat:boolean;                   {for bootstrap}
  54.         bootstrap:integer;              {"    "}
  55.         sample_no:string[19];           {"    "}
  56.  
  57. {**********************************************************************}
  58.  
  59.  
  60. {*********************************************************************}
  61. {$i nonfunc.pas}  {has function definition}
  62. {*********************************************************************}
  63.  
  64.  
  65.  
  66. procedure sum_of_residuals (var x:vector;matrix:input);
  67.                 {computes the sum of the squares of the residuals}
  68.                 {x(1..m) passes parameters. Result returned in x(n)}
  69. var
  70.         i:index;
  71.  
  72.  
  73. begin
  74.         x[n]:=0.0;
  75.         if debug then writeln ('np:= ',np);
  76.         for i:=1 to np do
  77.                 begin
  78.                 if debug then writeln (matrix[i,1],matrix[i,2]);
  79.                 x[n]:=x[n] + sqr (f(x,matrix[i])-matrix[i,nvpp]);
  80.                 if debug then writeln ('Sum of residuals--x[',i,']:= ',x[n]);
  81.                 end
  82.         end;    {sum of residuals}
  83.  
  84. {*******************************************************************}
  85.  
  86. procedure enter;
  87.                 {enters data from disk file fname}
  88.  
  89. var
  90.    f1:text;            {parameters for errors, starting points, incr}
  91.  
  92. begin                                                   {enter}
  93.         assign (f1, 'a:parms.dat');
  94.         reset (f1);
  95.         writeln(dout);
  96.         writeln(dout, 'Simplex optimization program              ');
  97.         writeln(dout,' Taken from Byte May 1984--written at FSU');
  98.         writeln(dout,'Adapted by Tom Dean, Dept. For. Res.,Utah State University');
  99.         writeln(dout);
  100.         writeln(dout,' accessing file ',fname);
  101.         read (f1,maxiter);
  102.         writeln(dout, 'maximum # of iterations is: ',maxiter:5);
  103.         write(dout,' start coord.: ');
  104.         for i:= 1 to m do
  105.                 begin
  106.                 read(f1,simp[1,i]);
  107.                 if (i mod lw)=0 then writeln (dout);
  108.                 write(dout,simp[1,i])
  109.                 end;
  110.         writeln(dout);
  111.         write(dout, ' start steps: ');
  112.         for i:=1 to m do
  113.                 begin
  114.                 read(f1,step[i]);
  115.                 if (i mod lw)=0 then writeln(dout);
  116.                 write(dout,step[i])
  117.                 end;
  118.         writeln(dout);
  119.         write(dout, ' max. errors: ');
  120.         for i:= 1 to n do
  121.                 begin
  122.                 read (f1,maxerr[i]);
  123.                 if (i mod lw)=0 then writeln(dout);
  124.                 write(dout,maxerr[i])
  125.                 end;
  126.         close (f1);
  127.         writeln(dout);
  128.         writeln(dout,' data: ');
  129.         writeln(dout,' x':14,'y':14);
  130.         np:=0;
  131.         while not EOF(din) do
  132.                 begin
  133.                 np:=succ(np);
  134.                 for j:= 1 to (nvpp-1) do read (din, data[np,j]);
  135.                 readln (din, data[np,nvpp]);
  136.                 end;
  137.         for j:=1 to 4 do
  138.             begin
  139.             for i:=1 to nvpp do write (dout, data[j,i]);
  140.             writeln (dout);
  141.             end;
  142.         writeln(dout);
  143.         writeln(dout, 'Total # of records read= ',np);
  144.         writeln(dout);
  145. end;{enter}
  146.  
  147.  
  148. {**********************************************************************}
  149.  
  150. procedure report;
  151. type
  152.     plotinp    = array [1..mnp] of real;
  153.     variable   = string[3];
  154. var
  155.         sumy, ssy, sstot, r2,
  156.         y,dy,
  157.         sigma:real;
  158.         k:integer;
  159.         ind,res,pred,obs         : plotinp;
  160.         xchar                    : variable;
  161.  
  162.  
  163. procedure plot (varx,vary:variable; m:integer;  x,y,yhat:plotinp);
  164. {if m neg then yhat plotted and its symbol takes precedence
  165. * = > 10 pts at a point}
  166.  
  167. const
  168.      y_sym  = 'o';
  169.      yhat_sym = 'p';
  170.      over_sym = '*';
  171.      xlen = 51;
  172.      ylen = 25;
  173.  
  174. type
  175.     points     = array [1..xlen, 1..ylen] of char;
  176.     counters =integer;
  177.  
  178. var
  179.    np,i,j,k,l                : counters;
  180.    done, plot_pred           : boolean;
  181.    graph                     : points;
  182.    xscale,yscale,yhscale,
  183.    xnext,ynext               : real;
  184.    xmin,xmax,ymin,ymax,
  185.    yhmin,yhmax, temp         : real;
  186.    symbol,tempsym            : char;
  187.    mx,my,myh                 : real;
  188.    x1,y1                     : integer;
  189.  
  190.  
  191. begin
  192. {find out if yhat to be plotted}
  193. if m < 0 then
  194. begin
  195.      plot_pred:=false;
  196.      m:=-m;
  197. end
  198. else plot_pred:=true;
  199.  
  200. fillchar(graph, sizeof(graph), $20);      {initialize graph to blanks}
  201.  
  202. {find max and mins}
  203. xmin:=x[1];
  204. xmax:=x[2];
  205. ymin:=y[1];
  206. ymax:=y[2];
  207. if Plot_pred then
  208. begin
  209.      yhmin:=yhat[1];
  210.      yhmax:=yhat[2];
  211. end;
  212. for i:=2 to m do
  213. begin
  214.      if xmin > x[i] then xmin:=x[i];
  215.      if xmax < x[i] then xmax:=x[i];
  216.      if ymin > y[i] then ymin:=y[i];
  217.      if ymax < y[i] then ymax:=y[i];
  218.      if plot_pred then
  219.      begin
  220.           if yhmin > yhat[i] then yhmin:=yhat[i];
  221.           if yhmax < yhat[i] then yhmax:=yhat[i];
  222.      end;
  223. end;
  224.  
  225. {calc scales increments}
  226. xscale:=(xmax-xmin)/(xlen-1);
  227. yscale:=(ymax-ymin)/(ylen-1);
  228. if plot_pred then
  229. begin
  230.      yhscale:=(yhmax-yhmin)/(ylen-1);
  231.      if yhscale > yscale then
  232.      begin
  233.           yscale:=yhscale;     {if yscale larger then use these max mins for stan}
  234.           ymax:=yhmax;
  235.           ymin:=yhmin;
  236.      end;
  237. end;
  238.  
  239.  
  240. {get ready to fill graph -- decide on symbols}
  241. if plot_pred then symbol:=y_sym  else symbol:='1';  { char 31h}
  242. {Standardize data to fit into graph space}
  243. mx:=(49)/(xmax-xmin);
  244. my:=(24)/(ymax-ymin);
  245. for i:=1 to m do
  246. begin
  247.      x1:=round(1+mx*(x[i]-xmin));
  248.      y1:=round(1+my*(y[i]-ymin));
  249.      if plot_pred then graph[x1,y1]:=symbol
  250.      else
  251.      begin
  252.           tempsym:=graph[x1,y1];
  253.           case tempsym of
  254.                ' ' : graph[x1,y1]:= symbol;
  255.                '9' : graph[x1,y1]:='*'
  256.                else graph[x1,y1]:=succ(tempsym);
  257.           end;
  258.      end;
  259. end;
  260.  
  261. {overlay predicted symbol on graph space}
  262. if plot_pred then
  263. begin
  264.      symbol:=yhat_sym;
  265.      for i:= 1 to m do
  266.      begin
  267.           x1:=round(1+mx*(x[i]-xmin));
  268.           y1:=round(1+my*(yhat[i]-ymin));
  269.           graph[x1,y1]:=symbol;
  270.      end;
  271. end;
  272.  
  273.  
  274. {output the plot}
  275. write (dout,'  Variable ',vary);
  276. if plot_pred then
  277.    writeln(dout,'   p = predicted   o = observed')
  278.    else writeln (dout);
  279. write(dout,'           ');
  280. writeln(dout,'-+---------+---------+---------+---------+---------+');
  281. ynext:=ymax;
  282. for j:= ylen downto 1 do
  283. begin
  284.      if (j mod 5) = 0 then
  285.      begin
  286.           write(dout,ynext:10,' +');
  287.           ynext:=ynext-yscale
  288.      end
  289.      else
  290.      begin
  291.           write (dout,'           |');
  292.           ynext:=ynext-yscale;
  293.      end;
  294.      for i:= 1 to xlen-1 do write (dout,graph[i,j]);
  295.      writeln (dout,graph[xlen,j]);
  296. end;
  297. write(dout,ynext:10,' ');
  298. writeln(dout,'-+---------+---------+---------+---------+---------+');
  299. xnext:=xmin;
  300. write (dout,'       ',xnext:8);
  301. for i:= 1 to 5 do
  302. begin
  303.      xnext:=xnext+xscale;
  304.      write (dout,'   ',xnext:8);
  305. end;
  306. writeln(dout);writeln(dout);
  307. writeln (dout,'                             Variable ',varx);
  308. writeln(dout);
  309. end; { PLOT }
  310. {************************************************************}
  311.  
  312.  
  313.  
  314. begin
  315.         writeln(dout,' program exited after',niter:5,' iterations');
  316.         writeln(dout);
  317.         writeln(dout,' the final simplex is');
  318.         for j:= 1 to n do
  319.                 begin
  320.                 for i:= 1 to n do
  321.                         begin
  322.                         if ( i mod lw)=0 then writeln(dout);
  323.                         write(dout,simp[j,i]:20)
  324.                         end;
  325.                 writeln(dout);
  326.                 end;
  327.         writeln(dout);
  328.         writeln(dout,' the mean is');
  329.         for i:=1 to n do
  330.                 begin
  331.                 if (i mod lw)=0 then writeln(dout);
  332.                 write(dout,mean[i]);
  333.                 end;
  334.         writeln(dout);
  335.         writeln(dout);
  336.         writeln(dout,' the estimated fractional error is');
  337.         for i:= 1 to n do
  338.                 begin
  339.                 if(i mod lw)=0 then writeln(dout);
  340.                 write(dout, error[i])
  341.                 end;
  342.         writeln(dout);
  343.         writeln(dout);
  344.         writeln (dout);
  345.         sumy:=0;
  346.         ssy:=0;
  347.         for i:= 1 to np do
  348.             begin
  349.             ssy:=ssy + sqr(data[i,nvpp]);
  350.             sumy:=sumy + data[i,nvpp];
  351.             end;
  352.         sstot:= ssy-sqr(sumy)/np;
  353.         r2:=(sstot-mean[n])/sstot;
  354.         writeln (dout, 'The approximate R-square is: ',r2);
  355.         writeln(dout);
  356.         sigma:=0.0;
  357.         for i:=1 to np do
  358.             begin
  359.              y:= f(mean, data[i]);
  360.              dy:=data[i,nvpp]-y;
  361.              sigma:=sigma+ sqr(dy);
  362.              end;
  363.         sigma:=sqrt(sigma/np);
  364.         writeln(dout,' the standard deviation is',sigma);
  365.         writeln(dout);
  366.         sigma:=sigma/sqrt(np-m);
  367.         write(dout,' the estimated error of the');
  368.         writeln(dout,' function is: ',sigma,^L,^G);
  369.  
  370.     if plots then
  371.     begin
  372.  
  373.         { Plot residuals by each independent variable}
  374.  
  375.         for j:= 1 to nvpp-1 do
  376.         begin
  377.              for i:= 1 to np do
  378.              begin
  379.                   ind[i]:= data[i,j];
  380.                   res[i]:=data[i,nvpp]-f(mean,data[i]);
  381.              end;
  382.              str(j,xchar);
  383.              plot (xchar,'res',-np,ind,res,res);
  384.              writeln(dout);writeln(dout);
  385.         end;
  386.         {this is a special plot for a specific function}
  387.         {*********************************************}
  388.         for i:= 1 to np do
  389.         begin
  390.              ind[i]:=data[i,1]*data[i,2];
  391.              res[i]:=data[i,nvpp]-f(mean,data[i]);
  392.         end;
  393.         plot('1*2','res',-np,ind,res,res);
  394.         {*********************************************}
  395.  
  396.         for j:=1 to nvpp-1 do
  397.         begin
  398.              for i:=1 to np do
  399.              begin
  400.                   ind[i]:=data[i,j];
  401.                   obs[i]:=data[i,nvpp];
  402.                   pred[i]:=f(mean,data[i]);
  403.              end;
  404.              str(j,xchar);
  405.              plot(xchar,'3',np,ind,obs,pred);
  406.          end;
  407.          {************************************************
  408.          this is a special graph for a particular function I use}
  409.          for i:=1 to np do
  410.          begin
  411.               ind[i]:=data[i,1]*data[i,2];
  412.               obs[i]:=data[i,nvpp];
  413.               pred[i]:=f(mean,data[i]);
  414.          end;
  415.          plot ('1*2','3',np,ind,obs,pred);
  416.          {************************************************}
  417.     end;
  418.  
  419.  
  420.  
  421. end;    {report}
  422.  
  423. {*********************************************************************}
  424.  
  425. procedure first;
  426.         begin
  427.         writeln(dout,' starting simplex');
  428.         for j:=1 to n do
  429.                 begin
  430.                 write(dout,' simp[',j:1,']');
  431.                 for i:=1 to n do
  432.                         begin
  433.                         if(i mod lw)=0 then writeln(dout);
  434.                         write(dout,simp[j,i])
  435.                         end;
  436.                 writeln(dout)
  437.                 end;
  438.         writeln(dout)
  439. end;    {first}
  440.  
  441. {*******************************************************************}
  442.  
  443. procedure new_vertex;           {next in place of the worst vertex}
  444. begin
  445.         if not stat then write(dout,' ---',niter:4);
  446.         for     i:=1 to n do
  447.                 begin
  448.                 simp[h[n],i]:=next[i];
  449.                 if not stat then write(next[i])
  450.                 end;
  451.         if not stat then writeln(dout);
  452. end;    {new vertex}
  453.  
  454. {********************************************************************}
  455.  
  456. procedure order;                {gives high.low in each parameter}
  457.                                 {in simp. CAUTION:NOT INITIALIZED}
  458. var
  459.         i,j:index;
  460.  
  461. begin
  462.         for j:=1 to n do
  463.                 begin
  464.                 for i:=1 to n do
  465.                         begin
  466.                         if simp[i,j] < simp[l[j],j] then l[j]:=i;
  467.                         if simp[i,j] > simp[h[j],j] then h[j]:=i
  468.                         end;
  469.                 end;
  470.         end;    {order}
  471.  
  472. {*******************************************************************}
  473. procedure simplex ( matrix:input);
  474. begin
  475. sum_of_residuals(simp[1],matrix);      {first vertex}
  476.  
  477.         for i:=1 to m do
  478.                 begin
  479.                 p[i]:=step[i]*(sqrt(n)+m-1)/(m*root2);
  480.                 q[i]:=step[i]*(sqrt(n)-1)/(m*root2);
  481.                 end;
  482.  
  483.         for i:=2   to n do
  484.                 begin
  485.                 for j:=1 to m do simp[i,j]:=simp[1,j]+q[j];
  486.  
  487.                 simp[i,i-1]:=simp[1,i-1]+p[i-1];
  488.                 sum_of_residuals(simp[i],matrix)
  489.                 end;
  490.  
  491.         for i:=1 to n do
  492.                 begin
  493.                 l[i]:=1;h[i]:=1
  494.                 end;
  495.  
  496.         order;
  497.  
  498.         if not stat then
  499.         begin
  500.         first;
  501.         if printer then
  502.            begin
  503.            assign(dout,'lst:');
  504.            rewrite(dout);
  505.            first;
  506.            assign(dout,'con:');
  507.            rewrite(dout);
  508.            end;
  509.         end;
  510.  
  511.         niter:=0;
  512.  
  513.         repeat
  514.         done:=true;
  515.         niter:=succ(niter);
  516.  
  517.         for i:=1 to n do center[i]:=0.0;
  518.         for i:=1 to n do
  519.                 if i <> h[n] then
  520.                         for j:=1 to m do
  521.                                 center[j]:=center[j]+simp[i,j];
  522.  
  523.         for i:=1 to n do
  524.                 begin
  525.                 center[i]:=center[i]/m;
  526.                 next[i]:=(1.0+alfa)*center[i]-alfa*simp[h[n],i]
  527.                 end;
  528.         sum_of_residuals(next,matrix);
  529.  
  530.         if next[n] <= simp[l[n],n] then
  531.                 begin
  532.                 new_vertex;
  533.                 for i:=1 to m do
  534.                         next[i]:=gamma*simp[h[n],i]+(1.0-gamma)*center[i];
  535.                 sum_of_residuals(next,matrix);
  536.                 if next[n] <= simp[l[n],n] then new_vertex
  537.                 end
  538.         else
  539.                 begin
  540.                 if next[n] <= simp[h[n],n] then
  541.                         new_vertex
  542.                 else
  543.                         begin
  544.                         for i:= 1 to m do
  545.                         next[i]:=beta*simp[h[n],i]+(1.0-beta)*center[i];
  546.                         sum_of_residuals(next,matrix);
  547.                         if next[n] <= simp[h[n],n] then
  548.                                 new_vertex
  549.                         else
  550.                                 begin
  551.                                 for i:= 1 to n do
  552.                                         begin
  553.                                         for j:=1 to m do
  554.                                         simp[i,j]:=
  555.                                         (simp[i,j]+simp[l[n],j])*beta;
  556.                                         sum_of_residuals(simp[i],matrix)
  557.                                         end
  558.                                 end
  559.                         end
  560.                 end;
  561.  
  562.         order;
  563.         for j:=1 to n do
  564.                 begin
  565.                 error[j]:=(simp[h[j],j]-simp[l[j],j])/simp[h[j],j];
  566.                 if done then
  567.                         if error[j] > maxerr[j] then
  568.                                 done:=false
  569.                 end
  570.  
  571.         until (done or (niter=maxiter));
  572.  
  573.         for i:=1 to n do
  574.                 begin
  575.                 mean[i]:=0.0;
  576.                 for j:= 1 to n do
  577.                         mean[i]:=mean[i]+simp[j,i];
  578.                 mean[i]:=mean[i]/n
  579.                 end;
  580. end;
  581. {****************************************************************************}
  582.  
  583. begin           {simplex main program}
  584. repeat
  585.         write ('Name of data file: ');
  586.         readln(fname);          {input file }
  587. {$i-}   assign(din,fname);      {fname is on disk}
  588.         reset (din);
  589. {$i+}   ok:=(ioresult=0);
  590.         if not ok then
  591.         begin
  592.              writeln ('Cannot find file ',fname);
  593.              writeln;
  594.         end;
  595. until ok;
  596.  
  597.         write(con, 'Plot residuals and fitted data? (Y/N): ');
  598.         read (kbd,response);
  599.         writeln(upcase(response));
  600.         if upcase(response) = 'Y'  then plots:=true else plots:=false;
  601.  
  602.         write (con, 'Save residuals and fitted data in files? (Y/N): ');
  603.         read(kbd,response);
  604.         writeln (upcase(response));
  605.         if upcase(response)= 'Y' then residual:= true else residual:=false;
  606.  
  607.         write ('Should output go to printer? (Y/N): ');
  608.         read (kbd,response);
  609.         writeln (upcase(response));
  610.         if upcase(response) = 'Y' then printer:=true else printer:=false;
  611.  
  612.         if printer then
  613.            begin
  614.            lowvideo;
  615.            writeln('Make sure printer is on.');
  616.            normvideo;
  617.            write('Enter descriptive title for run');
  618.            writeln('    Blank line terminates input');
  619.            repeat
  620.                  readln (title);
  621.                  writeln(lst,title);
  622.            until title = '';
  623.            end;
  624.         assign (dout,'con:');
  625.         rewrite(dout);
  626.         enter;                  {get the data}
  627.         if printer then
  628.            begin
  629.            assign(dout,'lst:');
  630.            rewrite(dout);
  631.            reset (din);
  632.            enter;
  633.            assign(dout,'con:');
  634.            rewrite(dout);
  635.            end;
  636. stat:=false;
  637. simplex(data);
  638.  
  639.         report;
  640.         if printer then
  641.            begin
  642.            assign(dout,'lst:');
  643.            rewrite(dout);
  644.            report;
  645.            end;
  646.  
  647. if residual then
  648. begin
  649.      i:=0;
  650.      repeat i:= i +1 until  (fname[i] = '.');
  651.      nerr:= copy(fname,1,(i-1)) + '.err';
  652.      nfit:= copy(fname,1,(i-1)) + '.fit';
  653.      writeln ;
  654.      writeln ('Residual and fit files written to ',nerr,' and ',nfit);
  655.      assign (ferr,nerr);
  656.      assign (ffit,nfit);
  657.      rewrite(ferr);
  658.      rewrite (ffit);
  659.      for i:= 1 to np do
  660.      begin
  661.           for j:= 1 to nvpp-1 do
  662.           begin
  663.                write (ferr, data[i,j]);
  664.                write (ffit, data[i,j]);
  665.           end;
  666.           writeln (ferr, data[i,nvpp]-f(mean, data[i]));
  667.           writeln (ffit, f(mean, data[i]));
  668.      end;
  669.      close (ferr);
  670.      close (ffit);
  671. end;
  672. { Beginning of bootstrap routine ++ Beware this can take forever without a
  673. math coprocessor}
  674. if variance then begin
  675. printer:=false;
  676. stat:=true;
  677. bootstrap:=1;
  678.  
  679. assign(fin,'sample');
  680. reset(fin);
  681. assign(fout,'b:bootstra');
  682. rewrite(fout);
  683.  
  684. repeat
  685.       readln(fin);
  686.       readln(fin,sample_no);
  687.       for i:=1 to np do
  688.       begin
  689.            read(fin,position);
  690.            data1[i]:=data[position];
  691.       end;
  692.       simplex(data1);
  693.       write(fout, bootstrap,' ');
  694.       write(con, bootstrap,' ');
  695.       for i:=1 to n do write (fout,mean[i]);
  696.       writeln(fout);
  697.       for i:=1 to n do write (con, mean[i]);
  698.       writeln(con);
  699.       readln(fin);
  700.       bootstrap:=bootstrap+1;
  701. until bootstrap = no_simplex+1;
  702. close (fin);
  703. close(fout);
  704. writeln (con, ^g,^g ,'          +++ DONE+++');
  705. end;{if variance}
  706.  
  707. end.
  708.  
  709.