I have known quadrature points (X_q) for q = 1, ..., Q and known frequency (A_q) at each point. I want to rescale X_q and A_q, so that I have the new X_q_new and A_q_new to satisfy sum(A_q_new*X_q_new) = 0 (i.e., mean = 0) and sum(A_q_new*(X_q_new)^2) = 1 (i.e., variance = 1)?

For example, X_q = [-2, -1, 0, 1, 2] and A_q = [0.2, 0.35, 0.1, 0.15, 0.2]. Note that sum(A_q) = 1 always. How to standardize this histogram?


Your statement of the requirements for standardisation is incorrect, since your equation for the sample variance is wrong. You have also given an example where the "frequencies" are not integer values (they are proportions). In my answer I will correct for this by assuming you can get values of $a$ that are your actual frequencies.

You have unique values $x_1, ..., x_Q$ with corresponding frequencies $a_1, ..., a_Q$, so you have $n = \sum a_i$ total data points. The sample mean and sample variance for your data are given by:

$$\bar{x} = \frac{\sum x_i a_i}{\sum a_i} \quad \quad s^2 = \frac{\sum (x_i - \bar{x})^2 a_i}{\sum a_i -1}.$$

These can be simplified by defining the statistics $m_n \equiv \sum x_i^n a_i$ for $n=0,1,2$. With a bit of algebra, we can then write these statistics as:

$$\bar{x} = \frac{m_1}{m_0} \quad \quad s^2 = \frac{m_2 m_0 - m_1^2}{m_0 (m_0-1)}.$$

Your studentised values (giving zero sample mean and unit sample variance) are:

$$y_q = \frac{x_q - \bar{x}}{s} = \frac{\sqrt{m_0 (m_0-1)}}{m_0} \cdot \frac{x_q m_0 - m_1}{\sqrt{m_2 m_0 - m_1^2}}.$$

You can easily use your data to calculate the statistics $m_0, m_1, m_2$ and then calculate these studentised values. The studentised value will have zero sample mean and unit sample variance, as desired.

| cite | improve this answer | |
  • $\begingroup$ Thank you for the clarifications. What does the subscript k mean? What is the value of x_k? $\endgroup$ – Keith Lau Apr 26 '18 at 6:35
  • $\begingroup$ To match your notation in the question, I've changed $k$ to $q$ - it is just an index for the $x$ value you are referring to. $\endgroup$ – Ben Apr 26 '18 at 7:17
  • $\begingroup$ Thanks. s_q is the new rescaled x, right? I ask because s was used to mean standard deviation. In addition, how to calculate the rescaled a here? $\endgroup$ – Keith Lau Apr 26 '18 at 7:22
  • $\begingroup$ Yes - I've now changed $s_q$ to $y_q$ so as not to duplicate notation. $\endgroup$ – Ben Apr 26 '18 at 7:24
  • $\begingroup$ There is no rescaling of $a_q$ - if two $x$ values are the same then they must be standardised to the same value, which means that the frequencies don't change. $\endgroup$ – Ben Apr 26 '18 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.