Tral.Randomness 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Tral.Randomness --version 1.0.0
NuGet\Install-Package Tral.Randomness -Version 1.0.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="Tral.Randomness" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tral.Randomness --version 1.0.0
#r "nuget: Tral.Randomness, 1.0.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.
// Install Tral.Randomness as a Cake Addin
#addin nuget:?package=Tral.Randomness&version=1.0.0

// Install Tral.Randomness as a Cake Tool
#tool nuget:?package=Tral.Randomness&version=1.0.0

TRAL.RANDOMNESS

TRAL.RANDOMNESS is a random number class library for C#. It provides common algorithm implementations and an extended set of random number routines which can be used with any algorithm.

Project Page: https://kuiper.zone/tral-randomness-csharp-prng/

QUICK START

Install the NuGet Release or download and build the source. Also available from NuGet.

Basic Routines

Here, we create a default generator and demonstrate a selection of routines:

using Tral.Randomness;

...

// This will initialize generator
var rand = new RandomGenerator();

// Integers
uint u32 = rand.Next32();
ulong u64 = rand.Next64();
int i32 = rand.NextInt(5, 10);
long i64 = rand.NextLong(-5, 10);

// Doubles
var d1 = rand.NextDouble();
var d2 = rand.NextDouble(0, 10);
var d3 = rand.NextOpenDouble();
var d4 = rand.NextStdNormal();

// Bytes
var b = rand.NextBytes(64);

// Shuffle
var shuffled = new int[]{0, 1, 2, 3, 4};
rand.Shuffle(shuffled);

// Strings
var s1 = rand.NextString(3, "TheAlphabet");
var s2 = rand.NextString(10, IRandomRoutines.AlphaNumericMixed);

Global Routines

For convenience, we can also use a singleton provided:

int i32 = RandomGenerator.Global.NextInt(5, 10);

The Global instance is local to the thread.

Algorithms

Declare the "internal algorithm" to be used as follows:

using Tral.Randomness;
using Tral.Randomness.Algorithms;

...

// Xoshiro256++
var xopp256 = new RandomGenerator<Xoshiro256pp>();

// Xoshiro256**
var xoss256 = new RandomGenerator<Xoshiro256ss>();

// WELL512
var well512 = new RandomGenerator<Well512>();

// MT19937-32
var mt32 = new RandomGenerator<MersenneTwister32>();

// MT19937-64
var mt64 = new RandomGenerator<MersenneTwister64>();

// ISAAC-32
var isaac32 = new RandomGenerator<Isaac32>();

// ISAAC-64
var isaac64 = new RandomGenerator<Isaac64>();

// SplitMix64
var split64 = new RandomGenerator<SplitMix64>();

// RAND48
var rand48 = new RandomGenerator<Rand48>();

We can pass references to any of the above, without having to specify the algorithm, using the interface types "IRandomGenerator" or "IRandomRoutines".

Seeding and Jumping

As follows:

// Not randomized (false)
var rand = new RandomGenerator<Xoshiro256pp>(false);

// Initialize
rand.Randomize();

// How many bytes do we need to seed?
Console.WriteLine(rand.SeedLength);

// Xoshiro256++ requires 32 bytes
rand.SetSeed(seedBytes);

// We can also seed with a simple integer, although how
// this is done by RandomGenerator is implementation specific.
rand.SetSeed(98765);

// And, where supported:
if (rand.IsJumpable)
{
    rand.Jump();
}

It is also possible to create your own algorithm by implementing the minimal interface "IRandomAlgorithm" or, more commonly: "ISeedableAlgorithm" or "IJumpableAlgorithm". This can then be used with RandomGenerator<TAlgo> which provides the extended routines. See SplitMix64 and Xoshiro256pp for straightforward implementation examples.

More Information

You should find TRAL.RANDOMNESS meaningfully documented by code comments.

Project Page: https://kuiper.zone/tral-randomness-csharp-prng/

Andy Thomas / https://kuiper.zone

NOTICE

Copyright 2020 Andy Thomas

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

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