-
Notifications
You must be signed in to change notification settings - Fork 30
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
1 parent
3483cbf
commit 343750e
Showing
35 changed files
with
282 additions
and
212 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
31 changes: 31 additions & 0 deletions
31
src/Perfolizer/Perfolizer.Tests/Mathematics/SignificanceTesting/SimpleEquivalenceTests.cs
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,31 @@ | ||
using Perfolizer.Mathematics.Common; | ||
using Perfolizer.Mathematics.SignificanceTesting; | ||
using Perfolizer.Mathematics.SignificanceTesting.MannWhitney; | ||
using Perfolizer.Metrology; | ||
|
||
namespace Perfolizer.Tests.Mathematics.SignificanceTesting; | ||
|
||
public class SimpleEquivalenceTests | ||
{ | ||
[Theory] | ||
[InlineData("[1,2,3,4,5,6,7,8,9,10]", "[1,2,3,4,5,6,7,8,9,10]", "1", ComparisonResult.Indistinguishable)] | ||
[InlineData("[195,195,196,196]", "[200.3279,200.3178,200.4046]", "1", ComparisonResult.Indistinguishable)] | ||
[InlineData( | ||
"[0.819,0.62,-0.742,0.572,1.43,-0.272,-0.34]", | ||
"[-0.539,-0.311,-0.174,1.186,-1.455,1.021,0.021]", | ||
"0.1", ComparisonResult.Indistinguishable)] | ||
[InlineData( | ||
"[200.3279, 200.3178, 200.4046, 200.3279, 200.3178, 200.4046, 200.3279, 200.3178, 200.4046, 200.3279, 200.3178, 200.4046]", | ||
"[195, 196, 195, 196, 195, 196, 195, 196, 195, 196, 195, 196, 195, 196, 195, 196, 195, 196, 195, 196]", | ||
"2%", ComparisonResult.Greater)] | ||
[InlineData( | ||
"[10070400,10073300,10073500]", | ||
"[9.7031,9.2344,10.1719,8.6094,9.5469,8.1406,8.6094,8.4531,7.9844,7.2031,8.1406,8.6094,9.0781,8.9219,9.2344,8.9219]", | ||
"2%", ComparisonResult.Greater)] | ||
public void TostTest(string x, string y, string threshold, ComparisonResult expected) | ||
{ | ||
var test = new SimpleEquivalenceTest(MannWhitneyTest.Instance); | ||
var actual = test.Perform(Sample.Parse(x), Sample.Parse(y), Threshold.Parse(threshold), SignificanceLevel.P1E5); | ||
Assert.Equal(expected, actual); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
src/Perfolizer/Perfolizer.Tests/Mathematics/SignificanceTesting/TostTests.cs
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
namespace Perfolizer.Tests; | ||
|
||
public class SampleTests | ||
{ | ||
[Theory] | ||
[InlineData("[1,2,3]ms", "[4]s", "[1,2,3,4000]ms")] | ||
[InlineData("[2000]KB", "[4]B", "[2048000,4]B")] | ||
public void SampleConcatTest(string a, string b, string c) | ||
{ | ||
string actual = Sample.Parse(a).Concat(Sample.Parse(b)).ToString(); | ||
string expected = Sample.Parse(c).ToString(); | ||
Assert.Equal(expected, actual); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Perfolizer/Perfolizer/Exceptions/InvalidMeasurementUnitExceptions.cs
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,6 @@ | ||
using Perfolizer.Metrology; | ||
|
||
namespace Perfolizer.Exceptions; | ||
|
||
public class InvalidMeasurementUnitExceptions(MeasurementUnit expected, MeasurementUnit actual) | ||
: InvalidOperationException($"Invalid measurement unit: expected {expected}, but was {actual}"); |
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
1 change: 0 additions & 1 deletion
1
src/Perfolizer/Perfolizer/Mathematics/EffectSizes/DiffEffectSize.cs
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
2 changes: 0 additions & 2 deletions
2
src/Perfolizer/Perfolizer/Mathematics/EffectSizes/IEffectSizeEstimator.cs
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
using Perfolizer.Common; | ||
|
||
namespace Perfolizer.Mathematics.EffectSizes; | ||
|
||
public interface IEffectSizeEstimator | ||
|
3 changes: 1 addition & 2 deletions
3
src/Perfolizer/Perfolizer/Mathematics/SignificanceTesting/Base/IEquivalenceTest.cs
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
using Perfolizer.Common; | ||
using Perfolizer.Mathematics.Common; | ||
using Perfolizer.Metrology; | ||
|
||
namespace Perfolizer.Mathematics.SignificanceTesting.Base; | ||
|
||
public interface IEquivalenceTest | ||
{ | ||
bool AreEquivalent(Sample x, Sample y, Threshold threshold, SignificanceLevel alpha); | ||
ComparisonResult Perform(Sample x, Sample y, Threshold threshold, SignificanceLevel alpha); | ||
} |
10 changes: 0 additions & 10 deletions
10
src/Perfolizer/Perfolizer/Mathematics/SignificanceTesting/Base/ITostEquivalenceTest.cs
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/Perfolizer/Perfolizer/Mathematics/SignificanceTesting/Base/TostEquivalenceResult.cs
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/Perfolizer/Perfolizer/Mathematics/SignificanceTesting/SimpleEquivalenceTest.cs
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,33 @@ | ||
using Perfolizer.Mathematics.Common; | ||
using Perfolizer.Mathematics.GenericEstimators; | ||
using Perfolizer.Mathematics.SignificanceTesting.Base; | ||
using Perfolizer.Metrology; | ||
|
||
namespace Perfolizer.Mathematics.SignificanceTesting; | ||
|
||
// TODO: replace the dummy implementation with a reliable one | ||
public class SimpleEquivalenceTest(ISignificanceTwoSampleTest oneSidedTest) : IEquivalenceTest | ||
{ | ||
public ComparisonResult Perform(Sample x, Sample y, Threshold threshold, SignificanceLevel alpha) | ||
{ | ||
var deltas = DeltasEstimator.HodgesLehmannShamos.Deltas(x, y); | ||
double thresholdShift = Max(threshold.GetMaxShift(x), threshold.GetMaxShift(y)); | ||
|
||
// Practical significance | ||
if (deltas.Shift.Abs() > thresholdShift * 10) | ||
return deltas.Shift > 0 ? ComparisonResult.Greater : ComparisonResult.Lesser; | ||
|
||
// Statistical significance (TOST) | ||
const AlternativeHypothesis alternative = AlternativeHypothesis.Greater; | ||
var greaterPValue = oneSidedTest.GetPValue(x, y, alternative, threshold); | ||
var lesserPValue = oneSidedTest.GetPValue(y, x, alternative, threshold); | ||
|
||
var comparisionResult = ComparisonResult.Indistinguishable; | ||
if (greaterPValue < alpha) | ||
comparisionResult = ComparisonResult.Greater; | ||
else if (lesserPValue < alpha) | ||
comparisionResult = ComparisonResult.Lesser; | ||
|
||
return comparisionResult; | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
src/Perfolizer/Perfolizer/Mathematics/SignificanceTesting/TostEquivalenceTest.cs
This file was deleted.
Oops, something went wrong.
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
6 changes: 6 additions & 0 deletions
6
src/Perfolizer/Perfolizer/Metrology/IAbsoluteMeasurementValue.cs
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,6 @@ | ||
namespace Perfolizer.Metrology; | ||
|
||
public interface IAbsoluteMeasurementValue : ISpecificMeasurementValue | ||
{ | ||
double GetShift(Sample sample); | ||
} |
6 changes: 0 additions & 6 deletions
6
src/Perfolizer/Perfolizer/Metrology/IApplicableMeasurementUnit.cs
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
src/Perfolizer/Perfolizer/Metrology/IRelativeMeasurementValue.cs
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,6 @@ | ||
namespace Perfolizer.Metrology; | ||
|
||
public interface IRelativeMeasurementValue : ISpecificMeasurementValue | ||
{ | ||
double GetRatio(); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/Perfolizer/Perfolizer/Metrology/ISpecificMeasurementValue.cs
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,5 @@ | ||
namespace Perfolizer.Metrology; | ||
|
||
public interface ISpecificMeasurementValue : IWithUnits | ||
{ | ||
} |
3 changes: 2 additions & 1 deletion
3
.../Perfolizer/Metrology/IFormattableUnit.cs → ...olizer/Perfolizer/Metrology/IWithUnits.cs
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
namespace Perfolizer.Metrology; | ||
|
||
public interface IFormattableUnit | ||
public interface IWithUnits | ||
{ | ||
MeasurementUnit Unit { get; } | ||
string ToString(string? format, IFormatProvider? formatProvider = null, UnitPresentation? unitPresentation = null); | ||
} |
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.