% filename: inference_example_1.m % This script plots the likelihood function for Example 1 in the Introduction to Inference presentation. In the example, WRW were the colors of three marbles drawn from a large bag, and the goal was to give plausible values for pi, the proportion of reds in the bag. % ********** % create a vector of candidate values of the parameter pi, and compute the likelihood L at each of those values. Note that .^ and .* are element-by-element exponentiation and multiplication respectively. p = [0:0.01:1]; L = p.*((1-p).^2); % plot the likelihood function against pi: plot(p,L) xlabel('\pi') ylabel('Likelihood L(\pi )')