Skip to main content
17 events
when toggle format what by license comment
S Jan 14, 2015 at 8:13 history bounty ended Dulguun Otgon
S Jan 14, 2015 at 8:13 history notice removed Dulguun Otgon
Jan 14, 2015 at 8:13 vote accept Dulguun Otgon
Jan 9, 2015 at 22:52 answer added leonbloy timeline score: 0
Jan 9, 2015 at 21:12 comment added user856 You need to store another variable, which is the total quantity seen so far, say $t_n$. Then the update formulas are $t_n = t_{n-1} + q_n$ and $m_n = (t_{n-1}m_{n-1} + a_nq_n)/t_n$. You didn't need to keep track of $t_n$ before because it was always equal to $n$.
S Jan 8, 2015 at 6:59 history bounty started Dulguun Otgon
S Jan 8, 2015 at 6:59 history notice added Dulguun Otgon Canonical answer required
Jan 8, 2015 at 6:58 history edited Dulguun Otgon CC BY-SA 3.0
added 40 characters in body
Dec 28, 2014 at 14:12 comment added Dulguun Otgon Ok thanks, but how accurate is that approach?
Dec 28, 2014 at 13:39 comment added Winther Now I think I know what you mean. You want $m = \frac{3+5+4}{1.5+2.5+1.0}$ right? This cannot be done with incremental averaging since the result on step $n$ depends on all the previous prices and there is no simple linear relationship between $m_n$ and $m_{n-1}$.
Dec 28, 2014 at 13:34 comment added Winther This is what I get: $m_1 = a_1 = 3/1.5 = 2.0$, $m_2 = m_1 + \frac{a_2-m_1}{2} = 2.0 + \frac{5/2.5-2.0}{2.0} = 2.0$, $m_3 = m_2 + \frac{a_3-m_2}{2} = 2.0 + \frac{4/1.0 - 2.0}{3.0} = 2.666$. What is wrong with this? Why do you think $2.4$ should be the correct result?
Dec 28, 2014 at 13:29 comment added Dulguun Otgon Tried that way the answer comes wrong. It should be for A=[3] Q=[1.5] m=2,A=[3,5] Q=[1.5,2.5] m=2, A=[3,5,4] P=[1.5,2.5,1] m=2.4
Dec 28, 2014 at 13:26 comment added Winther Then you first have to calculate the price per kilo first: $P = [3/1.5, 5/2.5, 4/1.0] = [2,2,4]$ then do incremental averaging on this array.
Dec 28, 2014 at 13:20 history edited Dulguun Otgon CC BY-SA 3.0
added 194 characters in body
Dec 28, 2014 at 13:17 comment added Dulguun Otgon Oh the problem I have to figure out is that let's say I bought apples several times. First 1.5kg for 3 dollars, second 2.5kg for 5 dollars, 1kg for 4 dollars. I need to calculate the average price per kg of apple incrementally.
Dec 28, 2014 at 13:10 comment added Winther What is $m_{1.5}$ supposed to mean? $n$ have to be an integer in $m_n$. I think you are a confusing the number of the element with the value of the element.
Dec 28, 2014 at 12:50 history asked Dulguun Otgon CC BY-SA 3.0