Skip to content

Commit

Permalink
[WIP] Introduce Phd
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyAkinshin committed Apr 1, 2024
1 parent 8d829c2 commit 080c432
Show file tree
Hide file tree
Showing 190 changed files with 3,974 additions and 232 deletions.
2 changes: 1 addition & 1 deletion src/Perfolizer/Perfolizer.Demo/QuantileEstimatorDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Run()
// * Akinshin, Andrey. "Trimmed Harrell-Davis quantile estimator based on the highest density interval of the given width."
// arXiv preprint arXiv:2111.11776 (2021).
// https://arxiv.org/abs/2111.11776
TrimmedHarrellDavisQuantileEstimator.SqrtInstance,
TrimmedHarrellDavisQuantileEstimator.Sqrt,
// The Sfakianakis-Verginis quantile estimators
// They use a weighted sum of all sample elements, weights are assigned according to the Binomial distribution
// * Sfakianakis, Michael E., and Dimitris G. Verginis. "A new family of nonparametric quantile estimators."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using JetBrains.Annotations;
using Perfolizer.Mathematics.Cpd;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;

namespace Perfolizer.Tests.Mathematics.Cpd;
namespace Perfolizer.SimulationTests.Cpd;

public class EdPeltTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
using JetBrains.Annotations;
using Perfolizer.Mathematics.Cpd;
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
using Perfolizer.SimulationTests.Cpd.TestDataSets;
using Perfolizer.Tests.Infra;
using Xunit.Abstractions;

namespace Perfolizer.Tests.Mathematics.Cpd;
namespace Perfolizer.SimulationTests.Cpd;

public class RqqPeltTests
public class RqqPeltTests(ITestOutputHelper output)
{
private readonly ITestOutputHelper output;
private readonly PeltChangePointDetector detector = RqqPeltChangePointDetector.Instance;

public RqqPeltTests(ITestOutputHelper output)
{
this.output = output;
}

[AssertionMethod]
private void Check(double[] data, int minDistance, int[] expectedChangePoints)
{
Expand All @@ -31,13 +26,13 @@ private void Check(double[] data, int minDistance, int[] expectedChangePoints)
public void Tie01() => Check(new double[]
{
0, 0, 0, 0, 0, 100, 100, 100, 100
}, 1, new[] {4});
}, 1, new[] { 4 });

[Fact]
public void Tie02() => Check(new double[]
{
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2
}, 1, new[] {5, 11});
}, 1, new[] { 5, 11 });

[Fact]
public void Check_WhenTwoMinDistanceLessThanDataLength_ReturnEmptyArray() => Check(new double[]
Expand All @@ -47,7 +42,7 @@ public void Check_WhenTwoMinDistanceLessThanDataLength_ReturnEmptyArray() => Che

[Fact]
[Trait(TraitConstants.Category, TraitConstants.Slow)]
public void ArithmeticProgression() => Check(Enumerable.Range(1, 500).Select(it => (double) it).ToArray(), 10, new[]
public void ArithmeticProgression() => Check(Enumerable.Range(1, 500).Select(it => (double)it).ToArray(), 10, new[]
{
9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109, 119, 129, 139, 149, 159, 169, 179, 189, 199, 209, 219, 229, 239,
249, 259, 269, 279, 289, 299, 309, 319, 329, 339, 349, 359, 369, 379, 389, 399, 409, 419, 429, 439, 449,
Expand Down Expand Up @@ -91,11 +86,13 @@ public void GaussianStdDevProgression(int error, string stdDevValuesString)
var indexes = detector.GetChangePointIndexes(data.ToArray(), 20);
Check100(stdDevValues.Length, error, indexes);
}

private static readonly IReadOnlyList<CpdTestData> ReferenceDataSet = CpdReferenceDataSet.Generate(new Random(42), 1);

private static readonly IReadOnlyList<CpdTestData> ReferenceDataSet =
CpdReferenceDataSet.Generate(new Random(42), 1);

[UsedImplicitly]
public static TheoryData<string> ReferenceDataSetNames = TheoryDataHelper.Create(ReferenceDataSet.Select(d => d.Name));
public static TheoryData<string> ReferenceDataSetNames =
TheoryDataHelper.Create(ReferenceDataSet.Select(d => d.Name));

[Theory]
[MemberData(nameof(ReferenceDataSetNames))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;
using Perfolizer.Mathematics.Randomization;

namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public static class CpdBinomialMeanProgressionDataSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;

namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public static class CpdFrechetLocationProgressionDataSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;

namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public static class CpdGaussianMeanProgressionDataSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;

namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public static class CpdGumbelLocationProgressionDataSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public static class CpdRealDataSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public static class CpdReferenceDataSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public class CpdTestData
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;

namespace Perfolizer.Tests.Mathematics.Cpd.TestDataSets;
namespace Perfolizer.SimulationTests.Cpd.TestDataSets;

public class CpdTestDataVerification
{
Expand Down
3 changes: 3 additions & 0 deletions src/Perfolizer/Perfolizer.SimulationTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global using System;
global using Xunit;
global using Xunit.Abstractions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0"/>
<PackageReference Include="xunit" Version="2.7.0"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Perfolizer.Tests\Perfolizer.Tests.csproj" />
<ProjectReference Include="..\Perfolizer\Perfolizer.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using JetBrains.Annotations;
using Perfolizer.Common;
using Perfolizer.Extensions;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Mathematics.ScaleEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;
using Xunit.Abstractions;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class ExtendedP2QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Perfolizer.Common;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;
using Xunit.Abstractions;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class GreenwaldKhannaQuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using JetBrains.Annotations;
using Perfolizer.Collections;
using Perfolizer.Common;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Mathematics.Randomization;
using Perfolizer.Mathematics.Sequences;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;
using Xunit.Abstractions;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class HarrellDavisQuantileEstimatorTests : QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;
using Xunit.Abstractions;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class HyndmanFanQuantileEstimatorTests : QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Text;
using Perfolizer.Common;
using Perfolizer.Extensions;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;
using Xunit.Abstractions;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class MovingP2QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Text;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public abstract class MovingQuantileEstimatorTestsBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using JetBrains.Annotations;
using Perfolizer.Common;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Mathematics.Randomization;
using Perfolizer.Mathematics.ScaleEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class P2QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using JetBrains.Annotations;
using Perfolizer.Collections;
using Perfolizer.Common;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Mathematics.Randomization;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

[UsedImplicitly]
public class PartitioningHeapsMovingQuantileEstimatorTests : MovingQuantileEstimatorTestsBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Perfolizer.Common;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public abstract class QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Perfolizer.Common;
using Perfolizer.Mathematics.QuantileEstimators;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class QuartilesTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using JetBrains.Annotations;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class SampleQuantileEstimatorTests : QuantileEstimatorTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.QuantileEstimators;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

[UsedImplicitly]
public class SimpleMovingQuantileEstimatorTests : MovingQuantileEstimatorTestsBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using JetBrains.Annotations;
using Perfolizer.Common;
using Perfolizer.Extensions;
using Perfolizer.Mathematics.Common;
using Perfolizer.Mathematics.Distributions.ContinuousDistributions;
using Perfolizer.Mathematics.QuantileEstimators;
using Perfolizer.Tests.Common;
using Perfolizer.Tests.Infra;
using Range = Perfolizer.Mathematics.Common.Range;

namespace Perfolizer.Tests.Mathematics.QuantileEstimators;
namespace Perfolizer.SimulationTests.QuantileEstimators;

public class SmokeQuantileEstimatorTests
{
Expand Down Expand Up @@ -68,7 +67,7 @@ static SmokeQuantileEstimatorTests()
("HF8", new HyndmanFanQuantileEstimator(HyndmanFanType.Type8)),
("HF9", new HyndmanFanQuantileEstimator(HyndmanFanType.Type9)),
("HD", HarrellDavisQuantileEstimator.Instance),
("THD", TrimmedHarrellDavisQuantileEstimator.SqrtInstance),
("THD", TrimmedHarrellDavisQuantileEstimator.Sqrt),
("SV1", SfakianakisVerginis1QuantileEstimator.Instance),
("SV2", SfakianakisVerginis2QuantileEstimator.Instance),
("SV3", SfakianakisVerginis3QuantileEstimator.Instance),
Expand Down
Loading

0 comments on commit 080c432

Please sign in to comment.