Re: Re: Jagged Spine (MultinormalDistribution)
- To: mathgroup at smc.vnet.net
- Subject: [mg82987] Re: [mg82972] Re: Jagged Spine (MultinormalDistribution)
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Tue, 6 Nov 2007 03:41:20 -0500 (EST)
- References: <fgk9or$pl6$1@smc.vnet.net> <3666327.1194260457176.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
I wondered why
MultinormalDistribution[{0, 0}, {{5, -3}, {-3, 2}}]
but
Eigenvectors[{{-1, -3/2}, {-3/2, -5/2}}, 1]
Where did the second matrix come from?
So I rewrote it:
<< MultivariateStatistics`
\[Mu] = {0, 0};
\[Chi] = {{5, -3}, {-3, 2}};
dist = MultinormalDistribution[\[Mu], \[Chi]];
phi = ArcTan @@ First@Eigenvectors[\[Chi], 1] // Simplify;
f[x_, y_] = PDF[dist, {x, y}];
g[x_, y_] =
f[x, y] /. Thread[{x, y} -> RotationMatrix[phi].{x, y}] //
Simplify;
This is rotated so that principle components are parallel to the axes:
gPlot = Plot3D[g[x, y], {x, -6, 6}, {y, -6, 6},
PlotPoints -> {25, 100}, PlotRange -> All]
This shows the original plot offset above the improved version (rotated to
the original axes):
fPlot = Plot3D[f[x, y] + 0.2, {x, -4, 4}, {y, -4, 4},
PlotPoints -> {50, 50}, PlotRange -> All];
Show[fPlot, gPlot /. x_GraphicsComplex :> Rotate[x, phi, {0, 0, 1}],
PlotRange -> {{-4, 4}, {-4, 4}, All}]
I'm not seeing a lot of jagged edges in the original, frankly.
Bobby
On Mon, 05 Nov 2007 04:04:38 -0600, <m.r at inbox.ru> wrote:
> On Nov 4, 5:17 am, Bruce Colletti <vze26... at verizon.net> wrote:
>> Re 6.0.1 under WinXP.
>>
>> The spine of the bivariate normal distribution below is jagged, even
>> when PlotPoints is set to 50 (took awhile to build). Altering
>> MaxRecursions is likewise no help.
>>
>> Is there a way to get a quickly-plotted smooth spine without resorting
>> to high values of PlotPoints? Thankx.
>>
>> Bruce
>>
>> Needs@"MultivariateStatistics`";
>>
>> Plot3D[PDF[MultinormalDistribution[{0, 0}, {{5, -3},{-3, 2}},{x, y}],
>> {x, -4, 4}, {y, -4, 4}, PlotRange -> All,
>> PlotPoints -> 50]
>
> Without Evaluate you're calling PDF for every function evaluation
> inside Plot. Also, you can reduce the quadratic form in the
> exponential to the principal axes and then you will need to refine the
> sampling only along one dimension:
>
> <<MultivariateStatistics`
> phi = ArcTan @@ First@ Eigenvectors[
> {{-1, -3/2}, {-3/2, -5/2}}, 1] // Simplify;
> f[x_, y_] = PDF[
> MultinormalDistribution[{0, 0}, {{5, -3}, {-3, 2}}],
> {x, y}] /.
> Thread[{x, y} -> RotationMatrix[phi].{x, y}] //
> Simplify
> Show[MapAt[Rotate[#, phi, {0, 0, 1}]&,
> Plot3D[f[x, y], {x, -6, 6}, {y, -6, 6},
> PlotPoints -> {100, 25}, PlotRange -> All],
> 1],
> PlotRange -> {{-4, 4}, {-4, 4}, All}]
>
> Maxim Rytin
> m.r at inbox.ru
>
>
>
--
DrMajorBob at bigfoot.com