![]() ![]() A basic implementation might look something like this: Brute Force ImplementationĪ simple moving average takes the sample values and divides them by the sample count. For example, you may wish to have older values to have more weight than newer ones, or vice-versa. This has the affect of making some items in the list more important (given more weight) than others. Weighted Moving AverageĪ weighted moving average is an average in which the data points in the list are given different multiplying factors. This is the easiest running average to implement and is the one I'm illustrating in this article. Simply Moving AverageĪ simple moving average is the unweighted mean (the sum of all items in a list divided by the number of items in the list) of the previous n data points. For an in-depth description, refer to wikipedia. What is a Running Average?Ī running average (also called a moving average) can be implemented in different ways. So I have written this article for beginners, to illustrate how even simple algorithms need some thought. In writing the code, I realized that even something as simple as a running average algorithm requires some thought to writing it well. I needed a running average to monitor CPU utilization and ended up writing a small class for doing the calculation.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |