-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from Microsoft/develop
Merge develop to master
- Loading branch information
Showing
25 changed files
with
1,650 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
| ||
namespace Microsoft.ApplicationInsights | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
internal static class EnumerableExtensions | ||
{ | ||
public static double StdDev(this IEnumerable<double> sequence) | ||
{ | ||
return StdDev(sequence, (e) => e); | ||
} | ||
|
||
public static double StdDev<T>(this IEnumerable<T> sequence, Func<T, double> selector) | ||
{ | ||
if (sequence.Count() <= 0) | ||
{ | ||
return 0; | ||
} | ||
|
||
double avg = sequence.Average(selector); | ||
double sum = sequence.Sum(e => Math.Pow(selector(e) - avg, 2)); | ||
|
||
return Math.Sqrt(sum / sequence.Count()); | ||
} | ||
} | ||
} |
Oops, something went wrong.