I have two finite sets of events $\{x_1, ..., x_N\}$ and $\{y_1, ..., y_N\}$ that are sampled from the PDFs $f(x)$ and $g(x)$, respectively, where $x \in [-1,+1]$. I want to estimate the Legendre expansion of $r(x) = f(x)/g(x)$ using these events. What is the best method? (Note that $g(x)\neq0$ over $[-1,1]$)
Legendre expansion of $r(x) = f(x)/g(x)$ using a finite number of samples from $f(x)$ and $g(x)$
numerical analysis;statistics;polynomials
I believe you are asking how to compute$$\frac{f(x)}{g(x)}\approx\sum_{n=0}^p a_n P_n(x).$$You could interpolate your samples of $f$ and $g$ to a uniform grid on $[-1,1]$, calculate the ratios at each of these points, and then use the trapezoid rule to calculate the integral$$\int_{-1}^1 P_n(x) \frac{f(x)}{g(x)} dx \approx \sum_j w_j P_n(x_j)\frac{f(x_j)}{g(x_j)},$$where $\{w_j,x_j\}$ represents the quadrature weights and abscissae, respectively. Given that I don't know what the functions $f,g$ behave like, I can't say much for the accuracy of this approach beyond that it should be OK if $f/g$ is smooth.