HistogramFill := proc (X::list,R::range,m::posint) local YYY, YY, Y, n, l, u, v, i, j, k, p, t, U, V, count, truemin, truemax, nint, pnts, pnts1, jj, P1, P2; option `July 7, 1993 -- Zaven A. Karian`; description `Graphic display of histogram`; YY := sort(evalf(args[1])); n := nops(YY); if nargs = 1 then truemin := YY[1]; truemax := YY[n]; nint := 8 else truemin := lhs(args[2]); truemax := rhs(args[2]); nint := args[3] fi; count := 0; for i to n do if YY[i] < truemin or truemax < YY[i] then count := count+1 fi od; if 0 < count then print(`WARNING: There are`,count,` data points out of plot range.`) fi; j := 1; YYY := array(1 .. n); u := array(1 .. nint+1); v := array(1 .. nint+1); for i to n do if truemin <= YY[i] and YY[i] <= truemax then YYY[j] := YY[i]; j := j+1 fi od; n := j-1; Y := [seq(YYY[k],k = 1 .. n)]; p := array(1 .. 8*nint); l := (truemax-truemin)/nint; u[1] := truemin; v[1] := 0; for i from 2 to nint+1 do u[i] := u[i-1]+l; v[i] := 0 od; if u[nint+1] < Y[n] then u[nint+1] := Y[n] fi; i := 2; for j to n do if Y[j] <= u[i] then v[i-1] := v[i-1]+1 else i := i+1; j := j-1 fi od; t := 1; for i to nint do U[t] := u[i]; V[t] := 0; t := t+1; U[t] := U[t-1]; V[t] := v[i]; t := t+1; U[t] := U[t-1]+l; V[t] := v[i]; t := t+1; U[t] := U[t-1]; V[t] := 0; t := t+1 od; for i to t-1 do p[2*i-1] := U[i]; p[2*i] := V[i]/(l*n) od; pnts := [seq([p[2*i-1], p[2*i]],i = 1 .. t-1)]; pnts1 := [seq([[pnts[4*(jj-1)+1], pnts[4*(jj-1)+2],pnts[4*(jj-1)+3], pnts[4*(jj-1)+4]]], jj = 1 .. nint)]: P1 := plots[polygonplot](pnts1,color=wheat): P2 := plot(pnts,color = black,linestyle = 1, thickness=2): display({P1,P2}); end: