* * Generation of graph on p 471 * data(unit=input) 1 10 c 5 0 1 1 0 3 2 3 4 1 * * This computes the Poisson likelihood for the sample. While we're showing this * as an example, this is a type of calculation that is best done in logarithms: * with a larger data set, or much larger numbers, it's quite possible for the * probability calculation to underflow, that is, become smaller than the smallest * positive number that can be represented in the computer's floating point * registers. * function poissonL theta local integer i compute poissonL=1.0 do i=1,10 compute poissonL=poissonL*exp(-theta)*theta**c(i)/%factorial(c(i)) end do i end * set grid 1 100 = .5+.03*t set like 1 100 = poissonL(grid(t))*10**7 set llike 1 100 = log(like)+25 * scatter(style=line,overlay=line,ovlabel="log L + 25",vlabel="Likelihood x 10**7",$ footer="Figure 17.1 Likelihood and Log-Likelihood Functions for a Poisson Distribution") 2 # grid like # grid llike