There are N samples $x_1, x_2, ...,x_N$ for random variable $X$.
I know Pearson's chi-squared test can be used to figure whether X follows uniform distribution.
First, discretize the range of $X$ and get $M$ classes. Then calculate $\chi^2=\sum\frac{(O_i-E_i)^2}{E_i}$ where $O_i$ is the number of samples belonging to class $i$, and $E_i$ equals to $\frac{N}{M}$. Finally compare $\chi^2$ to the critical value from the chi-squared distribution with $m-1$ degrees of freedom.
However, what if the samples are weighted. Say, $X$'s PDF is $p(x)$, and there is a weight function for the samples, and $f(x_1), f(x_2)..., f(x_N)$ are known. I want to know whether $p(x)f(x)$ is a uniform distribution. The original problem is a special case of this problem where $f(x_i) \equiv 1$.
Can chi-squared test be used in this problem? Or any other solutions?