Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5010 > unrolled thread
| Started by | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| First post | 2011-09-16 09:59 +0000 |
| Last post | 2011-09-16 09:59 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Question on SmoothKernelDistribution, value of computed bandwidth? (vrs. 8.01) "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-16 09:59 +0000
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Date | 2011-09-16 09:59 +0000 |
| Subject | Re: Question on SmoothKernelDistribution, value of computed bandwidth? (vrs. 8.01) |
| Message-ID | <j4v6mn$cb2$1@smc.vnet.net> |
On Thu, 15 Sep 2011 09:41:16 +0100, kristoph <kristophs.post@web.de> wrote:
> Hi
>
> Regarding the function SmoothKernelDistribution I'm aware that it is
> possible to compute the kernel pdf of some data. In order to do so
> Mathematica computes the bandwidth parameter if it is not provided.
>
> I was wondering if it is possible to retrieve the value of the
> computed bandwidth parameter somehow. I was unable to do so, but I
> think it is possible since Mathematica is computing and using it in
> order to compute the kernel pdf.
>
> Does anyone have an idea? Thanks in advance for help.
>
> Here is an example:
>
> data=RandomReal[1,1000];
> dist= SmoothKernelDistribution[data,
> "LeastSquaresCrossValidation", "Epanechnikov"];
> Plot[PDF[dist, x], {x, -1, 1}, Filling -> Axis, Exclusions -> None]
>
It is possible, but absolutely undocumented and reliant on functions that
are not meant to be exposed to or called by the user. Thus you should
apply the following only with extreme caution.
The bandwidth is calculated as follows:
bandwidth[data_, method_, kf_] := Block[
{
length = Length[data],
dim = Statistics`DataDistributionUtilities`KDEGetDimensionality[data],
sd = Statistics`DataDistributionUtilities`Dump`stDev[data]
},
Statistics`DataDistributionUtilities`Dump`iAutoBW[length, dim, sd,
method, data, kf]
]
or in your case,
In[2] :=
data=RandomReal[1,1000];
bandwidth[data, "LeastSquaresCrossValidation", "Epanechnikov"]
Out[3] = 0.0201149
Note that, depending on the data, this may give the message,
KernelMixtureDistribution::lscv: Unable to minimize the least squares
cross-validation function; Silverman's method will be used.
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web