2
$\begingroup$

I have an estimated distribution over a parameter, however, the distribution is not continuous, and InterpolatingPolynomial cannot estimate my distribution good enough, so I am going to use the Kernel distribution.

I have seen SmoothKernelDistribution function, but that applies only on a data. I already have a histogram, how can I find its kernel separately?

Lets say these are my histogram x and y axis :

positin of columns={0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5}
height= {0.000123464, 0.0086719, 0.119523, 0.394129, 0.36659, 0.105748, 0.00521382}

Thanks

$\endgroup$
1
$\begingroup$
positionofcolumns = {0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5};
height = {0.000123464, 0.0086719, 0.119523, 0.394129, 0.36659, 0.105748, 0.00521382};

You can use WeightedData with height as the weight vector:

wd = WeightedData[positionofcolumns, height]

SmoothHistogram[wd]

enter image description here

skd = SmoothKernelDistribution[wd]

Plot[PDF[skd, x], {x, 0,.8}]

enter image description here

$\endgroup$
  • $\begingroup$ Great, and how do you make it normalized?! sorry, it's a basic question I know. $\endgroup$ – aaa Aug 27 at 21:04
  • $\begingroup$ The integral over the finalized probability should be 1. In the final graph it's reaching 8. My original data points reach 0.34 . $\endgroup$ – aaa Aug 27 at 21:14
  • $\begingroup$ @aaa, PDF[skd,x] does integrate to 1: try NIntegrate[PDF[skd, x], {x,0, 1}]. Btw, values in height are not directly comparable to the height of the continuous PDF; you should get something comparable to the height of a bin if you integrate the pdf between the relevant bin limits. $\endgroup$ – kglr Aug 27 at 21:25
  • $\begingroup$ ok this is weird, I tried that and I'm getting something close to 1. If PDF is giving a probability of distribution then how can it be larger than 1 at some values? $\endgroup$ – aaa Aug 27 at 21:31
  • 2
    $\begingroup$ Total@{Probability[x < 0.225, x \[Distributed] skd], Probability[0.225 < x < 0.275, x \[Distributed] skd], Probability[0.275 < x < 0.325, x \[Distributed] skd], Probability[0.325 < x < 0.375, x \[Distributed] skd], Probability[0.375 < x < 0.425, x \[Distributed] skd], Probability[0.425 < x < 0.475, x \[Distributed] skd], Probability[x > 0.475, x \[Distributed] skd]} evaluates to 1. $\endgroup$ – Bob Hanlon Aug 28 at 3:38

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.