Chi-squared Distribution

STA256

STA258

STA260

\begin{document}
  \begin{tikzpicture}[xscale=0.8, yscale=10, domain=0:12, samples=100, every node/.style={font=\small}]
    % Draw axes
    \draw[->] (-0.2,0) -- (12.5,0) node[right] {$x$};
    \draw[->] (0,-0.02) -- (0,0.55) node[above] {$f(x; k, \theta)$};

    % Draw grid for better readability
    \draw[very thin, gray!30, step=1] (0,0) grid (12,0.5);

    % Gamma(1, 2) - Exponential
    \draw[thick, color=red] plot (\x, {0.5*exp(-0.5*\x)}) 
      node[right] at (1, 0.35) {$\Gamma(1,2)$};

    % Gamma(1.5, 2)
    \draw[thick, color=blue] plot (\x, {(sqrt(\x)*exp(-0.5*\x))/2.5066}) 
      node[right] at (2.5, 0.28) {$\Gamma(1.5,2)$};

    % Gamma(2, 2)
    \draw[thick, color=orange] plot (\x, {(\x*exp(-0.5*\x))/4}) 
      node[right] at (4.5, 0.2) {$\Gamma(2,2)$};

    % Gamma(3, 2)
    \draw[thick, color=teal] plot (\x, {(\x*\x*exp(-0.5*\x))/16}) 
      node[right] at (7, 0.12) {$\Gamma(3,2)$};

    % X-axis labels
    \foreach \x in {2,4,6,8,10,12}
      \draw (\x, 0.01) -- (\x, -0.01) node[below] {\x};

    % Y-axis labels
    \foreach \y in {0.1, 0.2, 0.3, 0.4, 0.5}
      \draw (0.1, \y) -- (-0.1, \y) node[left] {\y};

    % Legend or Title (optional)
    \node[draw, fill=white, anchor=north east] at (12, 0.5) {$\theta = 2$};
  \end{tikzpicture}
\end{document}