Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in R Programming by (50.2k points)

Let say, for instance, the X is a random variable in a density function which is constant between -2 and 3. I just want to know the upper quartile of X and the 44% quantile of X.

I have implemented the below code:

z <- 1 - punif(0.75, min = -2, max = 3, lower.tail = TRUE)

answer: 0.45

y <- qunif(0.44, min = -2, max = 3, lower.tail = TRUE)

answer: 0.2

First is this even the right way to go about it. Second, I know that Punif determines the aggregated probability of X. What does qunif obtain, and what does the result tell me about X and the distribution?

1 Answer

0 votes
by (108k points)

In the below code I am having a random variable x with a consistent distribution from a to b:

X ~ U(a,b)

Then punif(x, a, b) is the probability that U <= x

And qunif(x, a, b) finds the value y so that it can satisfy Pr(U <= y)=x

In R programming, you can visualize these plots with:

curve(punif(x, -2, 3), from=-2, to=3, main="punif")

curve(qunif(x, -2, 3), from=0, to=1, main="qunif")

Note how punif expects a value anywhere between a and b but qunif expects a probability so it must be between 0 and 1.

Browse Categories

...