2
$\begingroup$

I'm working with the sampling distribution of the sample mean and sample variance. For my data, I have the following sample mean = 0.418, standard deviation = 0.306, and degrees of freedom = 44. I've determined the 95% confidence interval (CI) is [0.3266,0.5099]

Below is the plot the Student t-distribution for these parameters. My questions are as follows:

  1. How can I color the area under this distribution to show the 95% CI?
  2. How can I use NIntegrate to verify the area between the 95% CI is 0.95?
Plot[PDF[StudentTDistribution[0.418, 0.306, 44], x], {x, -1, 2}, 
 PlotRange -> All, Filling -> Axis]
$\endgroup$
1
  • $\begingroup$ To find confidence intevals, look at 36827. $\endgroup$
    – Syed
    Nov 19, 2022 at 4:34

1 Answer 1

4
$\begingroup$

Try

pl1 = Plot[
   PDF[StudentTDistribution[mean = 0.418, stDev = 0.306, degFr = 44], 
    x], {x, -1, 2}, PlotRange -> All];
pl2 = Plot[
   PDF[StudentTDistribution[mean, stDev, degFr], x], {x, 0.3266, 
    0.5099}, PlotRange -> All, Filling -> Axis, 
   AxesOrigin -> {0, 0}];
Show[{pl1, pl2}]

But your confidence interval does not seem right, because the above gives: enter image description here

$\endgroup$
3
  • $\begingroup$ ya; I will have to look into that ... thank u Nicholas! $\endgroup$
    – user42700
    Nov 18, 2022 at 23:42
  • $\begingroup$ @PRG And the corresponding NIntegrate is NIntegrate[ PDF[StudentTDistribution[mean, stDev, degFr], x], {x, 0.3266, 0.5099}]. It is considered good form to accept and like answers. $\endgroup$
    – Nicholas G
    Nov 18, 2022 at 23:55
  • 1
    $\begingroup$ yes, Nicholas ... I hadn't finished the correspondence. $\endgroup$
    – user42700
    Nov 19, 2022 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.