-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
271 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Trivial.Maths; | ||
|
||
/// <summary> | ||
/// The functions of probability theory and mathematical statistics. | ||
/// </summary> | ||
public static partial class StatisticalMethod | ||
{ | ||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<double> Difference(IEnumerable<double> col) | ||
{ | ||
if (col == null) yield break; | ||
double? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<float> Difference(IEnumerable<float> col) | ||
{ | ||
if (col == null) yield break; | ||
float? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<decimal> Difference(IEnumerable<decimal> col) | ||
{ | ||
if (col == null) yield break; | ||
decimal? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<long> Difference(IEnumerable<long> col) | ||
{ | ||
if (col == null) yield break; | ||
long? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<int> Difference(IEnumerable<int> col) | ||
{ | ||
if (col == null) yield break; | ||
int? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<TimeSpan> Difference(IEnumerable<DateTime> col) | ||
{ | ||
if (col == null) yield break; | ||
DateTime? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a sequence about each item is different than before one of a specific numbers. | ||
/// </summary> | ||
/// <param name="col">The input numbers.</param> | ||
/// <returns>The increasement of each item.</returns> | ||
public static IEnumerable<TimeSpan> Difference(IEnumerable<TimeSpan> col) | ||
{ | ||
if (col == null) yield break; | ||
TimeSpan? test = null; | ||
foreach (var item in col) | ||
{ | ||
if (test.HasValue) yield return item - test.Value; | ||
test = item; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.