ProbHistFill := proc () local n, L, LL, lp, ap, A, MIN, dim, i,j, k, p, var, Min, Max, pnts1,pnts2,pnts, P1, P2, xtics; option `January 26, 1994 -- Zaven A. Karian, November 29, 1999, E. Tanis`; description `Graphic display of probability histogram`; if nargs = 1 and not type(args[1],list) then ERROR(`If one argument is used, it must be a probability list`) fi; if nargs = 2 and not type(args[1],algebraic) then ERROR(`If two arguments are used, the first must be an expression`) fi; if nargs = 2 and not type(args[2],range) then ERROR(`If two arguments are used, the second must be a range`) fi; if nargs = 1 then n := nops(args[1]); L := copy(args[1]); A := array(1 .. 4*n); lp := 1; ap := 1; for i to 1/2*n do A[ap] := L[lp]-1/2; A[ap+1] := 0; A[ap+2] := A[ap]; A[ap+3] := L[lp+1]; A[ap+4] := L[lp]+1/2; A[ap+5] := L[lp+1]; A[ap+6] := A[ap+4]; A[ap+7] := 0; LL[i] := [seq([A[ap + 2*j-2],A[ap + 2*j-1]],j=1..4)]; #LL[i] := [seq([A[ap+2*j-2], A[ap+2*j-1]], j=1..4)]: lp := lp+2; ap := ap+8; od; pnts2 := [seq([A[2*j-1], A[2*j]],j = 1 .. 2*n)]: pnts1 := [seq(LL[j], j = 1 .. n/2)]: P1 := plots[polygonplot](pnts1,color=wheat): xtics := [seq(k, k = 0 .. L[1]),seq(L[2*j+1], j = 0 .. n/2-1)]: #xtics := [seq(L[1] + j-1, j = L[1] .. ((L[n-1]-L[1])/2+1))]: P2 := PLOT(CURVES(pnts2), AXESTICKS(xtics,[0.05=`0.05`,0.1=`0.10`, 0.15=`0.15`, 0.2=`0.20`, 0.25=`0.25`, 0.3=`0.30`, 0.3=`0.35`])): display({P1,P2}): else Min := lhs(args[2]); Max := rhs(args[2]); dim := 8*trunc(Max-Min+1/1000000000)+8; A := array(1 .. dim); MIN := Min; var := op(select(type,indets(args[1]),name)); n := Max - Min + 1: for i to n do p := evalf(subs(var = MIN,args[1])); A[8*i-7] := MIN-1/2; A[8*i-6] := 0; A[8*i-5] := MIN-1/2; A[8*i-4] := p; A[8*i-3] := MIN+1/2; A[8*i-2] := p; A[8*i-1] := MIN+1/2; A[8*i] := 0; LL[i] := [seq([A[8*i-(8-2*j+1)],A[8*i-(8-2*j)]],j=1..4)]; MIN := MIN+1 od; pnts1 := [seq(LL[i], i = 1 .. n)]: pnts2 := [seq([A[2*i-1], A[2*i]],i = 1 .. 4*Max-4*Min+4)]; # plot(%,color = blue); P1 := plots[polygonplot](pnts1,color=wheat): xtics := [seq(Min + k-1, k = 1 .. (Max - Min+1))]: P2 := PLOT(CURVES(pnts2), AXESTICKS(xtics,[0.05=`0.05`,0.1=`0.10`, 0.15=`0.15`, 0.2=`0.20`, 0.25=`0.25`, 0.3=`0.30`, 0.3=`0.35`])): display({P1, P2}); fi end: