| Statistics Toolbox | ![]() |
Interactive contour plot of a function
Syntax
Description
fsurfht('fun',xlims,ylims)
is an interactive contour plot of the function specified by the text variable fun. The x-axis limits are specified by xlims in the form [xmin xmax], and the y-axis limits are specified by ylims in the form [ymin ymax].
fsurfht('fun',xlims,ylims,p1,p2,p3,p4,p5)
allows for five optional parameters that you can supply to the function fun.
The intersection of the vertical and horizontal reference lines on the plot defines the current x-value and y-value. You can drag these reference lines and watch the calculated z-values (at the top of the plot) update simultaneously. Alternatively, you can type the x-value and y-value into editable text fields on the x-axis and y-axis.
Example
Plot the Gaussian likelihood function for the gas.mat data.
Create a function containing the following commands, and name it gauslike.m.
function z = gauslike(mu,sigma,p1)
n = length(p1);
z = ones(size(mu));
for i = 1:n
z = z .* (normpdf(p1(i),mu,sigma));
end
The gauslike function calls normpdf, treating the data sample as fixed and the parameters µ and
as variables. Assume that the gas prices are normally distributed, and plot the likelihood surface of the sample.
The sample mean is the x-value at the maximum, but the sample standard deviation is not the y-value at the maximum.
| fstat | fullfact | ![]() |