# Gaussian fitting for ListSliceDensityPlot3D

My data has 4 columns which are (x,y,z,density) (https://drive.google.com/open?id=0B4YluTUi-LbELWpsOEVhckx0blU). I used command "ListSliceDensityPlot3D" to get the following figure.Now I want to fit a Gaussian distribution to the data. I think it should be a 3D ellipsoid. I don't know how to do. Who can tell me the method? Any suggestions are greatly appreciated.

This is an extended comment rather than an answer.

To fit a Gaussian distribution you would need a random sample from a Gaussian distribution. A grid of densities is not a random sample.

But suppose you wanted to find ellipsoid contours (essentially interpolating between the z values (0,-0.4, -0.8, -1.2, and -1.6). One would need the 5 slices to have a certain look-and-feel. Here are some contour plots of your slices:

Read in the data and split into the 5 slices.

myData = Import["mydata.csv", HeaderLines -> 1];
z00 = Select[myData, #[[3]] == 0 &];
z04 = Select[myData, #[[3]] == -0.4 &];
z08 = Select[myData, #[[3]] == -0.8 &];
z12 = Select[myData, #[[3]] == -1.2 &];
z16 = Select[myData, #[[3]] == -1.6 &];


Now produce some contour plots

contours = {1, 1.5, 2, 2.5, 3, 3.5};
shading = {Cyan, Orange, Green, Blue, Yellow, Red, Black};
GraphicsGrid[{{
ListContourPlot[z00[[All, {1, 2, 4}]], PlotLabel -> "z = 0", Contours -> contours, ContourShading -> shading],
ListContourPlot[z04[[All, {1, 2, 4}]], PlotLabel -> "z = -0.4", Contours -> contours, ContourShading -> shading],
ListContourPlot[z08[[All, {1, 2, 4}]], PlotLabel -> "z = -0.8", Contours -> contours, ContourShading -> shading]}, {
ListContourPlot[z12[[All, {1, 2, 4}]], PlotLabel -> "z = -1.2", Contours -> contours, ContourShading -> shading],
ListContourPlot[z16[[All, {1, 2, 4}]], PlotLabel -> "z = -1.6", Contours -> contours, ContourShading -> shading]}}]


I'm not seeing a good fit for an ellipsoid.

• Hi,@Jim Baldwin. Thank you for your suggestion. My current data is not good enough. If we just observe the "Blue" area, we can find the blue area in 3th slice is the biggest. The blue area in 2th and 4th slices are the medium.The blue area in 1th and 5th slices are the small. If we set the position (which has the biggest density value in 3th) as the (0,0,0) position, can you tell me how to fit a 3D Gaussian ellipsoid? I want to know the method. Once I have good data, then I can fit it quickly. Thank you very much. – Mr.2023 Mar 5 '17 at 8:45