Continuous Probability Example

pdf for X, Uniform[2,4] rv

Show[{Plot[0,{x,0,2}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}],
Plot[.5,{x,2,4}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[0,{x,4,6}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}] },PlotRange->{{0,6},{-0.001,.7}},AxesLabel->{" x ", "f[x] "}, PlotLabel->"Probability Density Function"]

cdf

The cdf is F[x_]:=(∫_(-∞)^x)f[t]dt.  For a Unif[2,4] rv, this is 0 for x<2, 1/2(x-2) on [2,4], and then 1.

Show[{Plot[0,{x,-1,2}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[1/2(x-2),{x,2,4}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[1,{x,4,6}, 
PlotStyle->{Red,Thickness[0.01]}]  },PlotRange->{{-1,6},{-0.001,1.01}},AxesLabel->{" x ", "F[x] "}, PlotLabel->"Cumulative Distribution Function"]

relate cdf to pdf

Clear[xValue];
xValue=2.8;

Show[{Plot[0,{x,0,2}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}],
Plot[.5,{x,2,4}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[.5,{x,2,xValue}, 
PlotStyle->{Red,Thickness[0.01]},Filling->Axis,FillingStyle->Orange],
Plot[0,{x,4,6}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}] },PlotRange->{{0,6},{-0.001,.7}},AxesLabel->{" x ", "f[x] "}, PlotLabel->"Probability Density Function"]

Clear[cumValue];
cumValue=(1/2(x-2))/.{x->xValue}

Show[{Plot[0,{x,-1,2}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[1/2(x-2),{x,2,4}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[cumValue,{x,-1,6}, 
PlotStyle->{Orange,Thickness[0.01]}],
Plot[1,{x,4,6}, 
PlotStyle->{Red,Thickness[0.01]}]  },PlotRange->{{-1,6},{-0.001,1.01}},AxesLabel->{" x ", "F[x] "}, PlotLabel->"Cumulative Distribution Function"]