I'm given a continuous random variable X and have the probability density function as below:
Now, i want to plot when b = 2, and since i wasn't provided with any dataset, i attempted something like:
I was wondering if I'm doing it correctly as it's my first time plotting a density function.


The pdf is given to you as a function of the parameter $b$
$$p(X=x|b ) =\begin{align}\begin{cases} \frac{2x}{b^{2}} & \textrm{ for } x \in [0,b] \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align}$$
then our density function is simply when we insert $b=2$
$$p(X=x|2 ) =\begin{align}\begin{cases} \frac{2x}{(2)^{2}} & \textrm{ for } x \in [0,2] \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align}$$
We simplify
$$p(X=x|2 ) =\begin{align}\begin{cases} \frac{x}{2} & \textrm{ for } x \in [0,2] \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align}$$
Using python here to create a graph