Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a random distribution of points in the $x\!-\!y$ plane. I can obtain a graphical representation of the probability distribution function using SmoothHistogram3D. Now I need to use this in another calculation. To do this I need a function that approximates SmoothHistogram3D.

Could you please tell me how to do it?

share|improve this question
5  
Look up SmoothKernelDistribution[]. –  J. M. Apr 26 '13 at 17:33
    
That was a brilliant suggestion J.M. I am over the moon. I tested it with NIntegrate by generating a PDF and it worked superbly. All the best. Eitan –  Eitan Abraham Apr 26 '13 at 19:49
1  
@J.M. this should be an answer –  Vitaliy Kaurov Apr 26 '13 at 20:03
add comment

1 Answer

At Vitaliy's behest:

You want the distribution SmoothKernelDistribution[], which can be treated like any other distribution by feeding it into PDF[], CDF[]...

Here's a comparison for reference:

BlockRandom[SeedRandom[197, Method -> "MersenneTwister"]; (* for reproducibility *)
            data = RandomVariate[BinormalDistribution[.75], 25]];

dist = SmoothKernelDistribution[data, "StandardGaussian", "Gaussian"];
{DensityPlot[PDF[dist, {x, y}], {x, -3.5, 3.8}, {y, -3.9, 4.2}, Mesh -> Automatic,
             MeshFunctions -> {#3 &}], 
 SmoothDensityHistogram[data, {"StandardGaussian", "Gaussian"}, "PDF"]} // GraphicsRow

smooth histogram comparison

share|improve this answer
1  
I appreciate that you include the bandwidth and kernel to show how they map from one function to the other. –  Brett Champion Apr 27 '13 at 2:42
    
I take the extra mile whenever feasible... :) –  J. M. Apr 27 '13 at 2:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.