Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Confidence contours in matlab

  1. Feb 12, 2012 #1

    I am dealing with a cosmological parameter estimation problem. I have a sum of squares function (chi-squared) of two parameters and I have minimized it using fminsearch, to find the best fit. Now, I want to plot 1-sigma, 2-sigma confidence contours for this. My parameter probability distribution may not be Gaussian. So , I don't want to do it in the usual way of adding 2.3 to chi-squared minimum and drawing the contour for 1-sigma. How can I draw a contour that encloses 68% of the area of the surface?

  2. jcsd
  3. Feb 13, 2012 #2


    User Avatar
    Science Advisor

    Well, if you want the entire contour that may not be Gaussian, you're probably going to want to use a Monte-Carlo Markov Chain, unless you already have an analytical result for the two-parameter probability distribution. Most people use cosmomc for MCMC's with cosmological parameter estimation. Cosmomc also includes a program, getdist, which can be used to produce a variety of different contour plots for chain outputs. It uses Matlab for the actual plotting.
  4. Feb 13, 2012 #3
    I already have an mcmc chain of parameter values and corresponding chi-square values. I have not used cosmomc though. Can you give me an idea how are the confidence regions estimated from the chain?
  5. Feb 13, 2012 #4


    User Avatar
    Science Advisor

    To obtain the posterior distribution, you chop the parameter's prior range into bins. Then, you count the number of chain steps that fall into each bin. The number in each bin is proportional to the marginal probability that the parameter value falls in that bin. Confidence intervals are then set by the parameter values within which a specified % of chain points lie. To obtain smooth 2D error contours, functions like getdist perform an interpolation on the 2D grid of binned chain points.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook