# Chi Squared Distribution using R

#### Lolita

##### New Member
Hi. How do I calculate P (1<x<4) for a chi squared distribution with degrees of freedom = 3 using R Programming ? What commands in R should I use for specifying the 2 intervals ?
I tried using chisq, pchisq .
I am not sure how to specify the command for continuous intervals.
Any help would be appreciated !!

#### GretaGarbo

##### Human
Code:
#compare with the 95% value for the chi-square for 1 deg of freedom
pchisq(3.84, df=1)

#P (1<X<4) = P(X<4) - P(X<1) =
pchisq(4, df=3) - pchisq(1, df=3)
#[1] 0.5397878

#### CB

##### Super Moderator
I think you are looking for:

Code:
pchisq(4, df = 3) - pchisq(1, df = 3)

#### CB

##### Super Moderator
Whoops, Greta and I posted the same answer simultaneously...

#### Dason

diff(pchisq(c(1,4), 3))