How to Plot Confidence Contours in Matlab for a Non-Gaussian Distribution?

  • MATLAB
  • Thread starter aymer
  • Start date
  • Tags
    Matlab
In summary, you can produce a contour plot that encloses 68% of the area of the surface using a Monte Carlo Markov Chain.
  • #1
aymer
16
0
Hello..

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?

thanx
 
Physics news on Phys.org
  • #2
aymer said:
Hello..

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?

thanx
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.
 
  • #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?
 
  • #4
aymer said:
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?
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.
 
  • #5


Hello there,

Thank you for reaching out with your question. Confidence contours can be a useful tool in parameter estimation, especially when dealing with non-Gaussian distributions. In Matlab, there are a few different ways to create confidence contours for your data.

One approach is to use the contour function, which allows you to specify the contour levels based on a given percentage of the total area. For example, for a 68% confidence contour, you can use the following code:

contour(x,y,Z,[chi2min chi2min+2.3],'ShowText','on')

where x and y are the parameter values, Z is the chi-squared function, and chi2min is the minimum value of chi-squared found by fminsearch. This will create a contour that encloses 68% of the total area under the chi-squared surface.

Another approach is to use the confidenceplot function from the Statistics and Machine Learning Toolbox. This function allows you to specify the confidence level and will automatically calculate the appropriate contour levels for you. For example, for a 68% confidence contour, you can use the following code:

confidenceplot(x,y,Z,'Confidence',0.68)

Both of these methods will give you a contour that encloses 68% of the total area, regardless of the shape of your parameter probability distribution.

I hope this helps and best of luck with your cosmological parameter estimation problem!
 

1. What are confidence contours in matlab?

Confidence contours in matlab are graphical representations of confidence intervals for a set of data. They show the uncertainty around a point estimate, typically with a certain level of confidence (e.g. 95%). These contours can help visualize the accuracy and precision of a measurement or model.

2. How do I create confidence contours in matlab?

To create confidence contours in matlab, you first need to have a set of data or a mathematical model. Then, you can use the built-in functions like contour() or contourf() to plot the contours. You can also use the Statistics and Machine Learning Toolbox for more advanced statistical analysis and confidence interval calculations.

3. What is the difference between confidence contours and confidence intervals?

Confidence contours and confidence intervals both represent the uncertainty around a point estimate. However, confidence contours are 2-dimensional representations and show the uncertainty in two variables, while confidence intervals are 1-dimensional and show the uncertainty in one variable.

4. How can I interpret confidence contours in matlab?

To interpret confidence contours in matlab, you need to understand the level of confidence (e.g. 95%), the scale of the axes, and the shape and orientation of the contours. A more circular and narrower contour indicates a more accurate and precise estimate, while a more elongated and wider contour indicates more uncertainty and potential error.

5. Can I change the color or style of confidence contours in matlab?

Yes, you can change the color, line style, and other properties of confidence contours in matlab. You can use the colormap() function to change the color scheme, and the LineStyle and LineWidth properties to change the style and thickness of the contours. You can also add labels, titles, and legends to make the plot more informative and visually appealing.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
735
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
717
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top