Continuous Probability Example

Example 1a, p206 Ross's A First Course in Probability, 7th Edition

X has pdf 3/8 (4x-2x^2) on (0,2) (and 0 otherwise).

pdf

you can get Mathematica to plot the nonzero part automatically, but it may not be as we would show it.

Plot[(3/8) (4 x-2 (x^2)),{x,0,2}]

if we wish to control the graphing window, we can use a little calculus

D[ (3/8) (4 x-2 (x^2)),x]

Solve[(3/8) (4-4 x)==0]

((3/8) (4 x-2 (x^2)))/.{x->1}

This is more complicated but more like the graph we would show.  I dashed the part on the axis is to make it show up better

Show[{Plot[0,{x,-10,0}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}],
Plot[(3/8) (4 x-2 (x^2)),{x,0,2}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[0,{x,2,10}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}] },PlotRange->{{-10,10},{-0.001,.78}},AxesLabel->{" x ", "f[x] "}, PlotLabel->"Probability Density Function"]

Show[{Plot[0,{x,-1,0}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}],
Plot[(3/8) (4 x-2 (x^2)),{x,0,2}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[0,{x,2,3}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}] },PlotRange->{{-1,3},{-0.001,.78}},AxesLabel->{" x ", "f[x] "}, PlotLabel->"Probability Density Function"]

cdf

The cdf is F[x_]:=(∫_(-∞)^x)f[t]dt

Certainly the area under the pdf to the left of 100 is zero.

For any x > 100, P(X<= x) = (∫_100^x)(100/(t^2))dt .

an almost manual effort

∫(3/8) (4 t-2 (t^2))\[DifferentialD]t

((((3 (t^2))/4)-((t^3)/4)) /.{t->x})-( (((3 (t^2))/4)-((t^3)/4))/.{t->0})

a more automated effort requires some work

Mathematica gives us what we want in this case.

(∫_0^x)(3/8) (4 t-2 (t^2))\[DifferentialD]t

the plot

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

relate cdf to pdf

Clear[xValue];
xValue=1.2;

Show[{Plot[0,{x,-1,0}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}],
Plot[(3/8) (4 x-2 (x^2)),{x,0,2}, 
PlotStyle->{Red,Thickness[0.01]}],
Plot[(3/8) (4 x-2 (x^2)),{x,0,xValue}, 
PlotStyle->{Red,Thickness[0.01]},Filling->Axis,FillingStyle->Orange],
Plot[0,{x,2,3}, 
PlotStyle->{Red,Thickness[0.01],Dashing[{.05,.1}]}] },PlotRange->{{-1,3},{-0.001,.78}},AxesLabel->{" x ", "f[x] "}, PlotLabel->"Probability Density Function"]

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

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