My Math Forum Averaging a series of numbers

 Elementary Math Fractions, Percentages, Word Problems, Equations, Inequations, Factorization, Expansion

 March 10th, 2016, 01:48 AM #11 Senior Member   Joined: Apr 2014 From: UK Posts: 955 Thanks: 342 Here's how I would do it: let 'A' be the average we currently have, in the original example this is 4.5 A= 4.5 let 'n' be the number of values we have averaged, in the original example this is 4. n= 4 let 'V' be the new value to add into the average, in the original example this is 7 V= 7 Now I need an equation to add a value into the average: New_Average = ((A x n ) + V ) / (n + 1 ) plugging in values: New_Average = ((4.5 x 4 ) + 7 ) / (4 + 1 ) = (18 + 7 ) / 5 = 5 This will work if you start from 0 and add in each of the example numbers in turn. Lets test it: A = 0, n = 0, V = 3 (the first number) New_Average = ((0 x 0 ) + 3 ) / (0 + 1 ) = 3 Next number: A = 3, n = 1, V = 2 (the second number) New_Average = ((3 x 1 ) + 2 ) / (1 + 1 ) = (3 + 2 ) / 2 = 2.5 Next number: A = 2.5, n = 2, V = 8 New_Average = ((2.5 x 2 ) + 8 ) / (2 + 1 ) = (5 + 8 ) / 3 = 4.33333 Next number: A = 4.33333, n = 3, V = 5 New_Average = ((4.3333 x 3 ) + 5 ) / (3 + 1 ) = (13 + 5 ) / 4 = 4.5 Thanks from stgeorge Last edited by weirddave; March 10th, 2016 at 01:49 AM. Reason: Numbers and brackets turned into emoticons!
 March 10th, 2016, 03:23 AM #12 Math Team   Joined: Jan 2015 From: Alabama Posts: 3,264 Thanks: 902 If you want to take averages "one number at a time" you will have to use "weighted averages". Of the four numbers, 3, 2, 8, 5, the average of the first two is (3+ 2)/2= 2.5. To "add" the third, 8, you have to "weight" 2.5- it was the average of 2 numbers so the weighted average is [2(2.5)+ 1()/3= 13/3.. Now, since that was the average 0f 3 numbers you "weight" it be 3 when you add the last number, 5: (3(13/3)+ 1(5))/4= 18/4= 4.5. That is, of course, essentially the same a (3+ 2+ 8+ 5)/4= 4.5 but with additional, unnecessary, multiplying and then dividing by the same number which is why averaging is NOT done that way- unless you have some special reason why you need the "intermediate" averages. Thanks from stgeorge
March 10th, 2016, 05:12 AM   #13
Senior Member

Joined: Apr 2014
From: UK

Posts: 955
Thanks: 342

That's exactly what it is doing, weighting the numbers.

The original question stated:

Quote:
 Originally Posted by stgeorge I would rather want to find the average value, gradually. .
There are devices which do this style of averaging on real world data, you end up seeing all the intermediate values as it builds up the average.

In my example, you don't have to start at 0, you can start with your known average and then add another number into it, but only if you know what the weighting is (which is the number of values that were averaged, 'n' in my equation).

I can't see where the multiplying and dividing by the same number was?

Last edited by weirddave; March 10th, 2016 at 05:18 AM. Reason: Added some text.

 March 10th, 2016, 06:19 AM #14 Senior Member   Joined: Apr 2014 From: Glasgow Posts: 2,157 Thanks: 732 Math Focus: Physics, mathematical modelling, numerical and computational solutions The mean of an existing sequence of $\displaystyle n$ numbers is this: old mean = $\displaystyle \bar{x_1} = \frac{1}{n}\sum_{i=1}^n x_n$ If we add a single value to the dataset, a new mean can be calculated as follows: new mean = $\displaystyle \bar{x_2} = \frac{1}{n+1}\sum_{i=1}^{n+1} x_n = \frac{1}{n+1} \left( \sum_{i=1}^{n} x_n + x_{n+1} \right) = \frac{1}{n+1} \left( n \bar{x_1} + x_{n+1} \right)$ If your algebra is shaky, the final equation translated into words is: new mean = ((old number of values x old mean) + new value) / new number of values Therefore you can update the mean as new values are added provided you keep track of how many numbers were used to get your previous mean. For example, let's say you calculate the mean of 3, 2 and 8. You perform $\displaystyle \bar{x} = \frac{3+2+8}{3} = \frac{13}{3}$ Now we add another value to the sequence, which is 5. We have: old number of values = 3 new number of values = 4 old mean = $\displaystyle \frac{13}{3}$ new value = 5 The new mean is therefore: $\displaystyle \bar{x} = \frac{\left( 3 \cdot \frac{13}{3} + 5 \right)}{4} = \frac{\left( 13 + 5 \right)}{4} = \frac{18}{4} = \frac{9}{2}$ (Note that a straight mean calculation gives $\displaystyle \frac{3 + 2 + 8 + 5}{4} = \frac{9}{2}$, so it works) As you add further numbers to your sequence, the mean will tend towards much smaller deviations as you add numbers to the series because the weighting for the existing series tends towards 1 and the weighting for the new value tends towards 0. Therefore, if you want to get an average that is more flexible, you can discard the oldest value in your dataset as you add another one, so you keep the number of values in your mean constant. This is called a "moving average". A good example of an application of the moving average is the average outside air temperature. Typically such averages are performed over a 24-hour period, so as new values come in, older ones are discarded. For more info on the moving average, check out this: https://en.wikipedia.org/wiki/Moving_average Thanks from stgeorge Last edited by Benit13; March 10th, 2016 at 06:22 AM.
 March 11th, 2016, 12:38 AM #15 Member   Joined: Jun 2012 Posts: 73 Thanks: 2 Thank you for the helpful replies: weirddave, Benit13, Country Boy. This is a wonderful community.

 Tags averaging, numbers, series

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post paxy Linear Algebra 1 March 9th, 2016 02:47 PM kapilab Algebra 2 October 11th, 2014 08:59 AM master555 Real Analysis 2 January 23rd, 2012 11:24 PM everk Real Analysis 2 September 5th, 2011 01:06 PM Torres Number Theory 4 December 22nd, 2008 03:33 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top