# program to fix up histogram (normalization, etc) and # prepare plots with both histogram and the analytical PDF # called AFTER a call to 'run' mkhist := proc(lambda, n_mea, n_smpls_per_mea) # global xacc, hist, bin_range, bin_size, n_bins, midpt, phi, pex; local histnorm_inv, bi, hi, exact_pdf; # # normalize histogram (histnorm_inv is INVERSE of normalization): histnorm_inv := 1. : # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- MODIFY -- # fill in correct form # Note histnorm_inv appears in the following line: for bi to n_bins do hist[bi] := hist[bi]*histnorm_inv od: # plot histogram: hi := [[midpt(n),hist[n]] $n=1..n_bins]: phi := plot(hi,x=0..bin_range+bin_size,style=point,symbol=circle,color=red): # plot exact probability density function exact_pdf := proc(x) global lambda; exp(-x/lambda)/lambda: end: pex := plot(exact_pdf(x),x=0..bin_range+bin_size,style=line,color=blue): end: