irbit1.dem

来自「Delphi Pascal 数据挖掘领域算法包 数值算法大全」· DEM 代码 · 共 42 行

DEM
42
字号
PROGRAM d7r10 (input,output);
(* driver for routine IRBIT1 *)
(* calculate distribution of runs of zeros *)
CONST
   nbin=15;
   ntries=500;
VAR
   i,iflg,ipts,iseed,j,n : integer;
   twoinv : real;
   delay : ARRAY [1..nbin] OF real;

(*$I MODFILE.PAS *)
(*$I IRBIT1.PAS *)

BEGIN
   iseed := 1234;
   FOR i := 1 to nbin DO BEGIN
      delay[i] := 0.0
   END;
   writeln ('distribution of runs of n zeros');
   writeln ('n':6,'probability':22,'expected':18);
   ipts := 0;
   FOR i := 1 to ntries DO BEGIN
      IF (irbit1(iseed) = 1) THEN BEGIN
         ipts := ipts+1;
         iflg := 0;
         FOR j := 1 to nbin DO BEGIN
            IF ((irbit1(iseed) = 1) AND (iflg = 0))
            THEN BEGIN
               iflg := 1;
               delay[j] := delay[j]+1.0
            END
         END
      END
   END;
   twoinv := 0.5;
   FOR n := 1 to nbin DO BEGIN
      writeln ((n-1):6,(delay[n]/ipts):19:4,twoinv:20:4);
      twoinv := twoinv/2.0
   END
END.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?