I'm trying to plot the Smooth Density Histogram of a double pendulum (particularly the location of the bottom pendulum). Since a pendulum has physical constraints, when shown in the Smooth Density Histogram there are unrealistic locations of probabilities (i.e. there is a probability at a location where it is impossible for the pendulum to reach because the smoothing function "smoothed" out to zero).
Is there a way to have a type of exclusion that dictates the physical constraints of the system, when applying the smoothing function.
For example the following code:
deqns = {Subscript[m, 1] x1''[
t] == (\[Lambda]1[t]/Subscript[l, 1]) x1[
t] - (\[Lambda]2[t]/Subscript[l, 2]) (x2[t] - x1[t]),
Subscript[m, 1] y1''[
t] == (\[Lambda]1[t]/Subscript[l, 1]) y1[
t] - (\[Lambda]2[t]/Subscript[l, 2]) (y2[t] - y1[t]) -
Subscript[m, 1] g,
Subscript[m, 2] x2''[
t] == (\[Lambda]2[t]/Subscript[l, 2]) (x2[t] - x1[t]),
Subscript[m, 2] y2''[
t] == (\[Lambda]2[t]/Subscript[l, 2]) (y2[t] - y1[t]) -
Subscript[m, 2] g};
aeqns = {x1[t]^2 + y1[t]^2 ==
Subscript[l, 1]^2, (x2[t] - x1[t])^2 + (y2[t] - y1[t])^2 ==
Subscript[l, 2]^2};
ics = {x1[0] == 1, y1[0] == 0, y1'[0] == 0, x2[0] == 1, y2[0] == -1,
y2'[0] == 0};
params = {g -> 9.81, Subscript[m, 1] -> 1, Subscript[m, 2] -> 1,
Subscript[l, 1] -> 1, Subscript[l, 2] -> 1};
soldp = First[
NDSolve[{deqns, aeqns, ics} /. params, {x1, y1, x2,
y2, \[Lambda]1, \[Lambda]2}, {t, 0, 15000},
Method -> {"IndexReduction" -> {"Pantelides",
"ConstraintMethod" -> "Projection"}}]];
will give the solution to a double pendulum (where each pendulum is of length one). ($t$ is really large so if you want to run it yourself feel free to bring it down an order of magnitude).
Looking at the smooth histogram,
SmoothDensityHistogram[
Map[Function[Evaluate[{x2[#], y2[#]} /. soldp]],
Range[0, 15000, 0.025]], Mesh -> 5,
PlotRange -> {{-2, 2}, {-2, 0.1}}]
you can see I only plotted to $y=-2$ to emphasis that there should not exist a probability after this point. So is there a way to force the smoothing function to not smooth anything outside of the boundary conditions i.e. Exclusions -> Function[{x, y}, x^2 + y^2 > 2^2]
RegionFunction -> Function[{x, y}, x^2 + y^2 <= 4]
give what you need? $\endgroup$MaxExtraBandwidths
usingSmoothKernelDistribution
on your data andDensityPlot
its pdf (PDF[SmoothKernelDistribution[ Map[Function[Evaluate[{x2[#], y2[#]} /. soldp]], Range[0, 2 1500, 0.025]], MaxExtraBandwidths ->0], {x, y}]
). $\endgroup$SmoothHistogramDensity
accepts anything but fixed bandwidths.SmoothKernelDistribution
does allow for adaptive bandwidths. An article that might be useful is sciencedirect.com/science/article/pii/S0047259X09001651. $\endgroup$