# Optimal Time Series Weight for Quantile Estimation

Given a time series, $$x_1$$, $$x_2$$, ..., $$x_t$$, .... I want to solve for $$\mathrm{min}_{w_1, w_2, ..., w_m}\rho(x_t-\mathrm{Quantile}(q; x_{t-1}, x_{t-2}, ..., x_{t-m}; w_{t-1}, w_{t-2}, ..., w_{t-m}))\textrm{ for }q\in(0, 1)$$ Here, $$\mathrm{Quantile}(q; x_{t-1}, x_{t-2}, ..., x_{t_m}; w_{t-1}, w_{t-2}, ..., w_{t-m})$$ is the $$q$$-th quantile of samples, $$x_{t-1}, x_{t-2}, ..., x_{t_m}$$ with weights, $$w_{t-1}, w_{t-2}, ..., w_{t-m}$$. And $$\rho(x)$$ is defined to be $$\rho(x)=q\cdot\mathrm{max}(x, 0)-(1-q)\cdot\mathrm{min}(x, 0)$$