Skip to main content
Pragmastat package icon

Pragmastat

v14.0.1Latest Stable
net10.0net6.0.NETStandard2.0

Pragmatic Statistical Toolkit

Published
Jul 26, 2026
2mo ago
Total Downloads
13.0M
12,959,905

Install

dotnet add package Pragmastat --version 14.0.1
ProductVersions
.NET
net10.0net6.0
.NET Standard
netstandard2.0

README

C#

Install from NuGet via .NET CLI:

dotnet add package Pragmastat --version 14.0.1

Install from NuGet via Package Manager Console:

NuGet\Install-Package Pragmastat -Version 14.0.1

Source code: https://github.com/AndreyAkinshin/pragmastat/tree/v14.0.1/cs

Pragmastat on NuGet: https://www.nuget.org/packages/Pragmastat/

Demo

using static System.Console;
using Pragmastat.Distributions;
using Pragmastat.Metrology;
using Pragmastat.Randomization;

namespace Pragmastat.Demo;

class Program
{
  static void Main()
  {
    // --- One-Sample ---

    var x = new Sample(Enumerable.Range(1, 200).Select(i => (double)i).ToArray());

    WriteLine(x.Center());                    // 100.5
    WriteLine(x.CenterBounds());              // [86;115]
    WriteLine(x.Spread());                    // 59
    WriteLine(x.SpreadBounds(1e-3, "demo")); // [44;87]

    // --- Two-Sample ---

    x = new Sample(Enumerable.Range(1, 200).Select(i => (double)i).ToArray());
    var y = new Sample(Enumerable.Range(101, 200).Select(i => (double)i).ToArray());

    WriteLine(x.Shift(y));                        // -100
    WriteLine(x.ShiftBounds(y));                  // [-120;-80]
    WriteLine(x.Ratio(y));                        // 0.5008354224706334
    WriteLine(x.RatioBounds(y));                  // [0.4066666666666668;0.5958333333333332]
    WriteLine(x.Disparity(y));                    // -1.694915254237288
    WriteLine(x.DisparityBounds(y, 1e-3, "demo")); // [-3.1025641025641026;-0.8494623655913979]

    // --- Confirmatory Comparison ---

    WriteLine(Toolkit.Compare1(x, [new Threshold(Metric.Center, new Measurement(50, MeasurementUnit.Number), 1e-3)])[0].Verdict.ToId()); // greater
    WriteLine(Toolkit.Compare2(x, y, [new Threshold(Metric.Shift, new Measurement(0, MeasurementUnit.Number), 1e-3)])[0].Verdict.ToId()); // less

    // --- Randomization ---

    var rng = new Rng("demo-uniform");
    WriteLine(rng.UniformDouble()); // 0.2640554428629759
    WriteLine(rng.UniformDouble()); // 0.9348534835582796

    rng = new Rng("demo-uniform-int");
    WriteLine(rng.UniformInt32(0, 100)); // 41

    rng = new Rng("demo-sample");
    WriteLine(string.Join(", ", rng.Sample([0.0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 3))); // 3, 8, 9

    rng = new Rng("demo-resample");
    WriteLine(string.Join(", ", rng.Resample([1.0, 2, 3, 4, 5], 7))); // 3, 1, 3, 2, 4, 1, 2

    rng = new Rng("demo-shuffle");
    WriteLine(string.Join(", ", rng.Shuffle([1.0, 2, 3, 4, 5]))); // 4, 2, 3, 5, 1

    // --- Distributions ---

    rng = new Rng("demo-dist-additive");
    WriteLine(new Additive(0, 1).Sample(rng)); // 0.17410448679568188

    rng = new Rng("demo-dist-multiplic");
    WriteLine(new Multiplic(0, 1).Sample(rng)); // 1.1273244602673853

    rng = new Rng("demo-dist-exp");
    WriteLine(new Exp(1).Sample(rng)); // 0.6589065267276553

    rng = new Rng("demo-dist-power");
    WriteLine(new Power(1, 2).Sample(rng)); // 1.023677535537084

    rng = new Rng("demo-dist-uniform");
    WriteLine(new Uniform(0, 10).Sample(rng)); // 6.54043657816832
  }
}

Changes from Previous Version

No structural changes between v14.0.0 and v14.0.1.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.