Calculate expected value from density function with constant

The formula for the expected value $\mu$ is the following:

$\mu = \sum_{i}x_i \cdot f(x_i)$

Given this density function:

$f(x) = C(9-x)^2$

For calculating the expected value do I have first to calculate the constant C or can I just use the term $(9-x)^2$ for the function?

$\sum_{i}x_{i}\cdot((9-x_{i})^2)$

or with calculated C = $\frac{1}{243}$

$\sum_{i}x_{i}\cdot(C \cdot (9-x_{i})^2)$


the formula for the expected value you showed is for discrete rv's.

For continuous rv's the expectation is

$$\mathbb{E}[X]=\int_{-\infty}^{\infty} x f_X(x)dx$$

Yours' is continuous...In order to calculate its expectation you have to specify its support...

Reading your result as $C=1/243$ I assume that your density is

$$f_X(x)=\frac{(9-x)^2}{243}\mathbb{1}_{[0;9]}(x)$$

thus your expectation is

$$\mathbb{E}[X]=\int_{0}^{9} \frac{x(9-x)^2}{243}dx=\frac{9}{4}$$