RNGenie.Distributions 0.1.0-alpha.2

This is a prerelease version of RNGenie.Distributions.
dotnet add package RNGenie.Distributions --version 0.1.0-alpha.2
                    
NuGet\Install-Package RNGenie.Distributions -Version 0.1.0-alpha.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RNGenie.Distributions" Version="0.1.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RNGenie.Distributions" Version="0.1.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="RNGenie.Distributions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RNGenie.Distributions --version 0.1.0-alpha.2
                    
#r "nuget: RNGenie.Distributions, 0.1.0-alpha.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RNGenie.Distributions@0.1.0-alpha.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RNGenie.Distributions&version=0.1.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=RNGenie.Distributions&version=0.1.0-alpha.2&prerelease
                    
Install as a Cake Tool

🎩 RNGenie.Distributions 📈

Lightweight Probability Distributions for Deterministic Sampling

RNGenie.Distributions provides ready-to-use sampling primitives (e.g. Uniform, Triangular, Gaussian-approx)
that integrate with IRandomSource for reproducible simulations.

NuGet Downloads .NET CI style: editorconfig


✨ Features

  • Common distributions (e.g. Uniform, Triangular, Gaussian approximation (using Box-Muller algorithm).
  • All samplers implement IDistribution<T>compose and test easily.
  • Deterministic when sampled with a seeded IRandomSource.

📄 Documentation

See the Distribution Docs for usage and API details.


🚀 Quick Start

Install Core + Distributions:

dotnet add package RNGenie.Core
dotnet add package RNGenie.Distributions

Basic usage:

using RNGenie.Core.Sources;
using RNGenie.Distributions.Continuous;

// Seedable RNG for reproducibility
var rng = new Pcg32Source(seed: 123);

// Sample from a Gaussian-like distribution
var normal = new Gaussian(mean: 0.0, stdDev: 1.0);
double x = normal.Sample(rng);

// Sample from a triangular distribution
var tri = Triangular(min: 0, mode: 10, max: 20);
double y = tri.Sample(rng);

Console.WriteLine($"Normal: {x:F3}, Triangular: {y:F3}");

Output:

Normal: -0.318, Triangular: 12.474

Implement your own distribution:

using RNGenie.Core.Abstractions;

public sealed class Bernoulli : IDistribution<bool>
{
	private readonly double _p;
	
	public Bernoulli(double p) => _p = Math.Clamp(p, 0.0, 1.0);
	
	public bool Sample(IRandomSource rng) => rng.NextDouble() < _p;
}

🧩 Extensibility

  • Build compound models by sampling multiple distributions.
  • Swap RNG sources (Pcg32Source, SystemRandomSource, CryptoRandomSource) without changing your model code.
  • Use the same seed to replay experiments exactly.

📦 Roadmap

  • Swappable Ziggurat algorithm for Gaussian distributions (currently uses Box-Muller).
  • Exponential, Poisson, Gamma, Beta, Binomial samplers.
  • Alias method for large discrete distributions.

👩‍💻 Contributing

Pull requests are welcome!

Good first issues:

  • Add new distributions + unit tests
  • Numerical validation harness

See CONTRIBUTING.md for guidance. Also, check here for existing distribution issue writeups.


📜 License

RNGenie is licensed under the MIT License. This means you're free to use it in open source, commercial, or personal projects.


Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha.2 45 9/13/2025
0.1.0-alpha.1 147 8/31/2025