[metapost] Plotting a Gaussian Distribution in MetaPost
L. Nobre G.
nobre at cii.fc.ul.pt
Fri Nov 9 17:30:44 CET 2007
On 08/11/2007, Kevin Liu <metapost.5.mezzopiano at spamgourmet.com> wrote:
> Hi,
>
> I am currently learning MetaPost, which, thanks to the great tutorials, is going
> quite well. I am mostly using it to plot graphs of functions, which has also been
> going quite well so far. However, I am experiencing significant difficulties in
> plotting a normal distribution - The only output I have been able to achieve was
> quite confusing.
Perhaps you could send your code...
You'll need an histogram of a gaussian distribution, for starters.
for l=1 upto totalnum:
tmp := normaldeviate;
for k=1 upto classnum:
if ( tmp <= k*classtep-lowrange ) and ( tmp > (k-1)*classtep-lowrange ):
histogram[k] := incr( histogram[k] );
fi;
endfor;
endfor;
> The graph package handles the task quite well, but it has limitations of its own. I
> would prefer an implementation directly in MetaPost to allow for maximum
> customisation.
What customization do you need?
> Do you know of any solutions to this problem?
What exactly is the problem?
> Could this be a symptom of the very small numbers involved?
No.
> Should I compute the numerical data and try to import it into MetaPost?
No.
> Do you know of any bézier approximations of the gaussian distribution?
I know some pocket calculators use a sort of bézier approximations of
the gaussian distribution. About five control points are enough.
Greetings
--
L. Nobre G. - http://burocracia.blogspot.com/
"The human species is entering a period of dramatic and potentially
devastating change as the result of forces of our own creation that
are now largely beyond our control. It is within our means, however,
to shape a positive outcome if we choose to embrace the resulting
crisis as an opportunity to lift ourselves to a new level of species
maturity and potential." David C. Korten in "The Great Turning"
More information about the metapost
mailing list