0
$\begingroup$

I apologize if the question is too simple but to me it's a bit difficult to see. I have certain data, let's say data in units of mass [kg] over a range of few years. I get the input of mass every 2 days during a period of 20 years. In theory the mass should be constant over time but it has a small variation each timestep. Thus, if I plot mass vs time I have a very noisy plot. In order to analyse the results in a better way, I would like to take the average of the mass every 2 years, so my average will have units of [mass/year]. Basically I want to spread the data over time. I also would like to associate a standard deviation to this average, but I'm not sure of how to compute it, due to the units I have. The equation for the mean is basically for this case (if I'm correct):

$\frac{\sum m_i}{Period = 2 yr}$

instead of the usual equation $\frac{\sum m_i}{N}$, where $m_i$ are the masses. For example using some data:

Time    Mass
[day]   [kg]
 2        3.5
 4        2.5
 6        3.7
 8        3.8
10        3.7
12        3.2
14        3.7
16        3.4
18        3.7
20        3.6

If I wanted to do the same but instead of a period of every two years, every 10 days then my first two points would be (using the first equation):

Period 1: 1.72 kg/day
Period 2: 1.76 kg/day. 

Now my question is how can I associate a standard deviation to each of the two past values?

I know that the standard deviation equation is: $\sqrt{\frac{1}{N} \sum (m_i - \hat{m}_i)^2}$

But with my units I don't see how to compute this. Or am I doing this in a wrong way? I think I can also just compute first the mean of the masses, using the second equation ($\sum m_i/N$)i.e.

Mean:
Period 1: 3.43 kg
Period 2: 3.52 kg

and then also estimate the standard deviation

Std:
Period 1: 0.48 kg
Period 2: 0.19 kg

and in the end I just know from the last example that in 2 days the mean for period 1 is 3.43 in two days so in 1 day it will be only half, Period 1: 1.71 kg/day and for Period 2: 1.76 kg/day and I estimate the standard deviation in the same way. Basically my question is how to use the equation for standard deviation in this case where I'm averaging over time with units rather than number of counts.

Thanks!

$\endgroup$
  • 3
    $\begingroup$ The premise isn't true though, the unit of the average of masses is still mass. Nowhere you should be dividing by time there, unless you mean something different. $\endgroup$ – Firebug May 8 '17 at 17:00
1
$\begingroup$

The units of the average of a quantity is always the units of the quantity itself. Your mistake is in the way you're interpreting the average.

Suppose, we want to take the time-average value of a quantity (say "mass"), which is a function of time, $M(t)$ between times $t_1$ and $t_2.$ The time-average value is $$ \langle M\rangle = \frac{\int_{t_1}^{t_2} M(t) dt}{t2 - t1}. $$ The numerator has units of "mass*time" and the denominator has units of "time". Thus the overall units of the average is "mass".

What you're doing is making the approximation that the mass is constant over a period of two days. If $t2 - t1$ is a period of two days, with a constant value $m$, then the integral becomes $m (t_2 - t_1) / (t_2 - t_1) = m.$ You're still doing the integral above, but it's a piecewise integral of constant values in each of their time windows. That's the approximation you're making.

If we have times $t_0, t_1, t_2, \dots, t_N$ in equally spaced increments with $t_i - t_{i-1} = \delta t$, and approximate $M(t) \approx m_i$ for $t_{i-1} < t \le t_i$ then $$ \begin{split} \langle M\rangle &= \frac{1}{t_N - t_0}\int_{t_0}^{t_N} M(t) dt \\ &\approx \frac{1}{N \delta t} \sum_{i=1}^N m_i \delta t \\ &= \frac{1}{N} \sum_i m_i, \end{split} $$ which is just the sample mean. Likewise,

$$ \begin{split} Var(M) &= \frac{1}{t_N - t_0} \int_{t_0}^{t_N} (M(t) - \langle M \rangle )^2 dt \\ &\approx \frac{1}{N \delta t} \sum_{i=1}^N (m_i - \langle M \rangle)^2 \delta t \\ &= \frac{1}{N} \sum_{i=1}^N (m_i - \langle M \rangle )^2 \end{split} $$ which is just the sample variance.

$\endgroup$
0
$\begingroup$

I think you are conflating two things. First, you want to convert your data from units of kg/(2 days) to kg/day. This is done by dividing the data by a factor of 2.

Secondly, you want to compute the mean and SD of your data over a given period of time. But this is a separate operation, and in fact because the unit conversion is linear in this case, the order in which you do these two operations doesn't matter. You can first take the mean of your original data and then divide this by two, or you can do the opposite: $$ \frac{1}{N}\sum_i \frac{1}{2} m_i = \frac{1}{2N}\sum_i m_i $$ That is: $\operatorname{mean}\left(\frac{X}{2}\right)=\frac{1}{2}\operatorname{mean}\left(X\right)$

The same is true for the standard deviation: $$ \sqrt{\frac{1}{N}\left(\frac{1}{2}m_i-\left<\frac{1}{2}m_i\right> \right)^2}=\sqrt{\frac{1}{4N}\left(m_i-\left<m_i\right> \right)^2}=\frac{1}{2}\sqrt{\frac{1}{N}\left(m_i-\left<m_i\right> \right)^2} $$ I.e.: $\operatorname{SD}\left(\frac{X}{2}\right)=\frac{1}{2}\operatorname{SD}\left(X\right)$

Using these equations, you would get means for your two periods of 1.72 kg/day and 1.76 kg/day (same as you got) and standard deviations of 0.240 and 0.097 kg/day, respectively (i.e. half the numbers you reported at the end).

So conceptually, the point to understand is that computing these statistics and changing the units of your values are two separate operations. You're interested in the mean and SD of your converted data (in units of kg/day) so in general you would first do that conversion, and then compute your statistics on this converted data which now has the right units. And note if your conversion was non-linear, e.g. if you took the log of your original units, you would have to do this conversion first or you'd get a wrong answer out.

$\endgroup$
  • $\begingroup$ Thank you for the explanation. It helped with my confusion. $\endgroup$ – user3412058 May 9 '17 at 7:58
  • $\begingroup$ Don't understand why this was downvoted? If there's something wrong with my answer I'd like to know what it is so I can correct/improve it. $\endgroup$ – Ruben van Bergen May 9 '17 at 16:09
  • $\begingroup$ I'm not sure. I don't have enough reputation to vote/unvote. Sorry $\endgroup$ – user3412058 May 10 '17 at 7:29
  • $\begingroup$ No worries - I'm glad my answer was helpful to you! =) $\endgroup$ – Ruben van Bergen May 10 '17 at 9:19

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.