[Roam-commit] SF.net SVN: roam: [86] Trunk/Source
Status: Alpha
Brought to you by:
jonfroehlich
|
From: <jon...@us...> - 2007-07-24 07:40:36
|
Revision: 86
http://roam.svn.sourceforge.net/roam/?rev=86&view=rev
Author: jonfroehlich
Date: 2007-07-24 00:40:33 -0700 (Tue, 24 Jul 2007)
Log Message:
-----------
1. updated Buffer AddRange (untested)
2. added StandardDeviation to MathUtils
Modified Paths:
--------------
Trunk/Source/Roam.Common/Collections/Buffer.cs
Trunk/Source/Roam.Common/Utils/MathUtils.cs
Trunk/Source/Roam.suo
Modified: Trunk/Source/Roam.Common/Collections/Buffer.cs
===================================================================
--- Trunk/Source/Roam.Common/Collections/Buffer.cs 2007-07-23 07:25:14 UTC (rev 85)
+++ Trunk/Source/Roam.Common/Collections/Buffer.cs 2007-07-24 07:40:33 UTC (rev 86)
@@ -20,7 +20,8 @@
namespace Roam.Common.Collections
{
/// <summary>
- ///
+ /// A finite sized memory structure. When the MaxItems count is reached, the next object added
+ /// to the buffer causes the first item to be removed (in a FIFO fashion).
/// </summary>
/// <remarks>
///
@@ -134,10 +135,23 @@
public virtual void AddRange(T[] items)
{
- while (_listItems.Count + items.Length >= _maxItems)
+ //jeffixme test this method
+ if (items.Length >= _maxItems)
{
- _listItems.RemoveFirst();
+ _listItems.Clear();
+ int startIndex = items.Length - _maxItems;
+ for (int i = 0; i < _maxItems; i++)
+ {
+ _listItems.AddLast(items[startIndex + i]);
+ }
}
+ else
+ {
+ while (_listItems.Count + items.Length >= _maxItems)
+ {
+ _listItems.RemoveFirst();
+ }
+ }
foreach (T t in items)
{
Modified: Trunk/Source/Roam.Common/Utils/MathUtils.cs
===================================================================
--- Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-07-23 07:25:14 UTC (rev 85)
+++ Trunk/Source/Roam.Common/Utils/MathUtils.cs 2007-07-24 07:40:33 UTC (rev 86)
@@ -86,6 +86,22 @@
return S / (n - 1);
}
+ /// <summary>
+ /// To understand standard deviation, keep in mind that variance is the average of the squared
+ /// differences between data points and the mean. Variance is tabulated in units squared.
+ /// Standard deviation, being the square root of that quantity, therefore measures the spread
+ /// of data about the mean, measured in the same units as the data.
+ /// </summary>
+ /// <param name="values"></param>
+ /// <returns></returns>
+ public static double StandardDeviation(ICollection<double> values)
+ {
+ double variance = Variance(values);
+ //the standard deviation is the square root of the variance
+ //http://en.wikipedia.org/wiki/Standard_deviation
+ return Math.Sqrt(variance);
+ }
+
public static Pair<double, double> MinMax(ICollection<double> values)
{
double max = double.MinValue;
Modified: Trunk/Source/Roam.suo
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|