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?

  • 5
    $\begingroup$ Look up SmoothKernelDistribution[]. $\endgroup$ – J. M. will be back soon Apr 26 '13 at 17:33
  • $\begingroup$ 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 $\endgroup$ – Eitan Abraham Apr 26 '13 at 19:49
  • 1
    $\begingroup$ @J.M. this should be an answer $\endgroup$ – Vitaliy Kaurov Apr 26 '13 at 20:03

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

  • 1
    $\begingroup$ I appreciate that you include the bandwidth and kernel to show how they map from one function to the other. $\endgroup$ – Brett Champion Apr 27 '13 at 2:42
  • $\begingroup$ I take the extra mile whenever feasible... :) $\endgroup$ – J. M. will be back soon Apr 27 '13 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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