1

Hello I wanna create a Normal distributed figure. with sigma = 10 and mu =185;

I have the following code based on Bi-variate Normal distribution

\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}    
\begin{tikzpicture}[
        declare function={mu=185;}, %
        declare function={sigma=10;}, %
        declare function={normal(\m,\s)=1/(2*\s*sqrt(pi))*exp(-(x-\m)^2/(2*\s^2));}] %
        \begin{axis}[
        width=15cm,
        enlargelimits=false,
        grid=major,
        domain=-1:4,
        y domain=-1:4,
        samples=201,
        xlabel=$x_1$,
        ylabel=$P$,
        ]
        \addplot [domain=150:220,samples=201, samples y=0, thick, smooth] (x,4,{normal(mu,sigma)});
        \end{axis}
    \end{tikzpicture}
\end{document}

The thing is that i get every time the following error.

Paragraph ended before \pgfflt@readlowlevelfloat was complete
\begin{axis} on input line 480 ended by \end{document}. \end{document}
Missing \endgroup inserted \end{document}

What does I wrong? The stupid thing is that when I copy the original it works fine and mine less big version doesn't work…

I hope somebody can help me

Thanks

Jan-Bert
  • 525
  • 1
    Do you want to create a three-dimensional plot, like in the answer you linked to, or just a two-dimensional one (like your use of \addplot instead of \addplot3 suggests)? – Jake Apr 23 '15 at 12:20
  • Maybe Plotting bell shaped curve in TikZ-PGF might be a better starting point for your purposes. – Jake Apr 23 '15 at 12:38
  • I want create a 2 dimensional as i did. The link was mine example.
    Both methods have to come to the same result isn't it? What is than the difference??
    But still i don't understand why my latex won't run and gives errors...
    – Jan-Bert Apr 23 '15 at 12:51
  • 1
    Use \addplot [domain=150:220,samples=201,thick, smooth] {normal(mu,sigma)}; – Jake Apr 23 '15 at 12:55
  • @Jan-Bert Coordinate (x,4,{normal(mu,sigma)}) is 3D coordinate... – Paul Gaborit Apr 23 '15 at 14:16
  • 2
    There is an error in the declaration of normal function: it is necessary to change (2*\s*sqrt(pi)) for (\s*sqrt(2*pi)) – jpayansomet Apr 24 '15 at 08:52
  • 2
    Thanks for the Tips it works.
    another thing. I try to get arrows under my figure like showed in Plotting bell shaped curve in TikZ-PGF.
    I can't figure out why \draw [yshift=-0.6cm, latex-latex](axis cs:-10,0) -- node [fill=white] {$x_1$} (axis cs:-15,0); doesn't work. I don't get any error. But it doesn't show anything eighter…
    – Jan-Bert Apr 24 '15 at 12:11
  • 5
    I'm voting to close this question because it was solved in the comments. – Stefan Pinnow Jun 23 '17 at 05:13
  • @Jan-Bert Don't use comments to ask another question. – Schweinebacke Jun 23 '17 at 06:23
  • 1
    @StefanPinnow I do not like close because answered in comment. IMHO adding an answer should always be preferred and closing would prevent everyone from doing this. – Schweinebacke Jun 23 '17 at 06:25
  • @Schweinebacke, in general I agree, but for me it is ok, when it either was "a simple" solution like here, where it was a "typo" of OP, or (also like here) it is an "old" question. – Stefan Pinnow Jun 23 '17 at 06:39

0 Answers0