[Tex/LaTex] Probability density function of Uniform Distribution

tikz-pgf

Can anyone help me about drawing pdf of uniform distribution function in Latex? I am newbie in this and could not find anything helpful. Thanks!

Best Answer

If anyone has interest, here is another solution with symbolic coordinates.

\documentclass[10pt]{standalone}
\usepackage{mathtools}

\usepackage{tkz-euclide}

% arrow and line for 'tkzPointShowCoord'
\makeatletter
\tikzset{arrow coord style/.style={%
    densely dashed,
    \tkz@euc@linecolor,
    %>=stealth',
    %->,
    }}
    \tikzset{xcoord style/.style={%
    \tkz@euc@labelcolor,
    font=\normalsize,text height=1ex,
    inner sep = 0pt,
    outer sep = 0pt,
    fill=\tkz@fillcolor,
    below=6pt
    }} 
\tikzset{ycoord style/.style={%
    \tkz@euc@labelcolor,
    font=\normalsize,text height=1ex, 
    inner sep = 0pt,
    outer sep = 0pt, 
    fill=\tkz@fillcolor,
    left=6pt
    }}  
\makeatother

\begin{document}

\begin{tikzpicture}
\tkzInit[xmax=1,xstep=0.2,ymax=1,ystep=0.2]
\tkzDrawX[noticks,label={$x$}]
\tkzDrawY[noticks,label={$f_X(x)$}]
\tkzDefPoint(0.2,0.8){A}
\tkzDefPoint(0.8,0.8){B}
\tkzDefShiftPoint[A](-90:4){AB}
\tkzDefShiftPoint[B](-90:4){BB}
\tkzDefShiftPoint[AB](0:-0.6){ABL}
\tkzDefShiftPoint[BB](0:0.6){BBR}
\tkzPointShowCoord[xlabel=$a$,ylabel=$\frac{1}{b-a}$](A)
\tkzPointShowCoord[xlabel=$b$](B)
\tkzDrawSegments[color=cyan,thick](A,B AB,ABL BB,BBR)
\tkzDrawPoints[color=cyan,fill=cyan,size=6pt](A,B)
\tkzDrawPoints[color=cyan,fill=white,size=6pt](AB,BB)
\end{tikzpicture}

\end{document}

enter image description here