Tuna.Probabilistic 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tuna.Probabilistic --version 0.1.0
                    
NuGet\Install-Package Tuna.Probabilistic -Version 0.1.0
                    
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="Tuna.Probabilistic" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tuna.Probabilistic" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Tuna.Probabilistic" />
                    
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 Tuna.Probabilistic --version 0.1.0
                    
#r "nuget: Tuna.Probabilistic, 0.1.0"
                    
#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 Tuna.Probabilistic@0.1.0
                    
#: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=Tuna.Probabilistic&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Tuna.Probabilistic&version=0.1.0
                    
Install as a Cake Tool

Tuna

日本語 (Japanese)

Tiny Utilities for Numerical Analysis — A pure C#, SIMD-accelerated numerical computing library for .NET 10.

Tuna provides fast linear algebra, special functions, and deterministic random/quasi-random generators with zero native dependencies, alongside modular extension packages for statistics, signal processing, optimization, integration, automatic differentiation, MCMC, and neural networks.

Key Features

  • Pure C# & Zero Native Dependencies: Runs anywhere .NET 10 runs, with SIMD-accelerated kernels and no native BLAS/LAPACK binaries to deploy.
  • Zero-Copy Views (readonly ref struct): Transpose (A.T), slice (A[1..3, ..]), row/column/diagonal views, and explicit zero-copy broadcasting (v.Broadcast(cols)) without allocating.
  • Allocation-Aware API: Elementwise and linear algebra operations in XMath provide allocating, destination-based, and XMath.InPlace overloads—plus reusable decomposition buffers (Recompute).
  • Modular Packages: Use Tuna for core numerics, and combine domain-specific Tuna.* packages as needed.

Packages

Package Description
Tuna Core package: Vector<T>, Matrix<T>, Tensor<T>, XMath, BLAS & decompositions (LU/Cholesky/QR/Eigen/SVD), special functions, PRNG/QRNG
Tuna.Statistics Continuous, discrete, and multivariate probability distributions (PDF/CDF/quantiles/sampling)
Tuna.SignalProcessing 1D/2D FFT, real FFT, DCT/DST, convolution, correlation, and discrete/continuous wavelets
Tuna.Optimization L-BFGS / L-BFGS-B, SGD / Adam / AdamW, proximal methods (FISTA/ADMM), global optimization, genetic algorithms
Tuna.Integration 1D adaptive quadrature, multidimensional cubature, and quasi-Monte Carlo integration
Tuna.Differentiation Tape-based reverse-mode automatic differentiation for scalars, vectors, matrices, tensors, and decompositions
Tuna.Probabilistic MCMC samplers (HMC, NUTS, slice, ensemble, parallel tempering) and convergence diagnostics ($\hat{R}$, ESS, MCSE)
Tuna.NeuralNetwork 2D convolution, Mamba blocks, normalization layers, and SafeTensors reader

Quick Start

Linear Algebra & Zero-Copy Views

using Tuna;
using Tuna.LinearAlgebra;

var A = Matrix<double>.FromRowMajor(3, 3,
[
    4, 1, 0,
    1, 3, 1,
    0, 1, 2,
]);
var b = new Vector<double>([1.0, 2.0, 3.0]);

// Solve A * x = b
Vector<double> x = XMath.Solve(A, b);

// Cholesky decomposition
var chol = A.Cholesky();
double logDet = chol.LogDeterminant;

// Zero-copy transpose, slicing, and broadcasting
Matrix<double> C = A.T * A[0..3, 0..2];
Vector<double> rowMeans = XMath.RowMeans(A);
XMath.Subtract(A, rowMeans.Broadcast(A.Columns), A); // center columns in-place

Allocation Control (XMath)

Most XMath operations provide three consistent forms:

var v = new Vector<double>([0.0, 1.0, 2.0]);
var buffer = new Vector<double>(v.Length);

Vector<double> y = XMath.Exp(v);     // 1. Allocate a new container
XMath.Exp(v, buffer);                // 2. Write into an existing destination buffer
XMath.InPlace.Exp(v);                // 3. Mutate in-place

Special Functions & Deterministic RNG

using Tuna;
using Tuna.RandomSource;

double logGamma = XMath.Special.LogGamma(200.0);
double tail = XMath.Special.Erfc(6.0);

var rng = new Pcg64DxsmRandom(seed: 42);
double u = rng.NextDouble();

Extension Packages (e.g. Reverse-Mode Autodiff)

using Tuna;
using Tuna.Differentiation;

var tape = new Tape();
var x = tape.Leaf(2.0);
var y = XMath.Sin(x) + x * x;
tape.Backward(y);
double dydx = tape.GetGradient(x); // cos(2) + 4

Design Highlights

  • Column-Major Layout: Matrix<T> stores elements in column-major order. Datasets follow the convention of 1 column = 1 sample (dimensions × samples).
  • No Implicit Broadcasting: Shapes must match explicitly; use v.Broadcast(cols) / v.BroadcastRows(rows) to create zero-copy broadcast views.
  • Strict Aliasing Rules: Elementwise operations allow exact-match in-place updates (partial overlap throws ArgumentException). Matrix products, transposes, and reductions forbid input/output overlap.

Requirements

  • .NET 10 (net10.0)

Documentation

Detailed guides, design notes, and generated API references are available in documents/ (Japanese):

License

This library is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.2.0 0 11/27/2026
0.1.0 51 11/26/2026