# How to find the probability density function?

John wants to buy a bag of candies
The price of the jar is $10$\$and the candies cost$25$\$ for 100 grams
The weight of the candies in the jar has continuous uniform distribution on the interval (100,150)

Basically I mean the weight distribution is U(100,150)

Now I need to find the probability density function of the price of the jar (the entire price-including the candies of course) and the type of it.

I thought to myself that it would also be a uniform distribution but I feel like I miss something here

• The only unknown factor is the weight of the candies, which is uniformly distributed, hence the entire price is also uniformly distributed. – barak manos May 20 '16 at 11:28

At first, lets estimate heuristically what we're going to get:

The minimal amount is a can with 100g, so the price is 10 + 25 = 35. It is obvious that further price follows uniform distribution and the price of maximal amount is 10 + 1.5*25 = 47.5. The uniform density should look like

$$f_Y(y) = \frac{1}{b-a} = \frac{1}{47.5-35} = \frac{1}{12.5}, \ \ y \in [35;47.5].$$

Ok, now lets read the formula for transformation of random variable:

Let $Y = g(X)$, then

$$f_Y(y) = f_X(g^{-1}(y)) \cdot \big|\frac{d}{dy}g^{-1}(y) \big|.$$

In our case, $f_X(x) = \frac{1}{150-100} = \frac{1}{50}, \ x \in [100;150]$ and $g(x) = 10 + \frac{25}{100}x = 10 + \frac{1}{4}x$.

Then $g^{-1}(y) = 4(y-10)$ and $\frac{d}{dy}g^{-1}(y) = 4$.

$$f_Y(y) = \frac{1}{50}\cdot 4 = \frac{1}{12.5}.$$

The last thing are limits, we have $g(x_{min}) = 10 + 100/4 = 35$ and $g(x_{max}) = 10 + 150/4 = 47.5$, so finally

$$f_Y(y) = \frac{1}{12.5}, \ \ y \in [35;47.5].$$

Hint:

In general if $U$ is uniformly distributed over interval $[0,1]$ then $$a+(b-a)U$$ is uniformly distributed over interval $[a,b]$.

P.S. provided that $b>a$.