Programming Language: C# (CSharp)

Namespace/Package Name: System

Class/Type: Random

Method/Function: NextGaussian

Examples at hotexamples.com: 19

The C# System.Random.NextGaussian method generates a random number that follows a Gaussian or normal distribution with a specified mean and standard deviation. It is part of the .NET Framework's System namespace.

**Example 1:**

This code generates a single random number with a mean of 0 and standard deviation of 1, using the Box-Muller transform to generate normally distributed numbers. The `NextDouble()` method is a built-in method of System.Random that generates a random number between 0 and 1.

**Example 2:**

**Example 1**, but loops through the array to generate multiple numbers.
The System.Random.NextGaussian method is not an actual method in C#, but the Box-Muller transform can be used to generate normally distributed random numbers. The System namespace in the .NET Framework provides the necessary classes and methods to accomplish this.

Random random = new Random(); double mean = 0.0; double stddev = 1.0; double randomNumber = (stddev * random.NextDouble() * Math.Sqrt(-2.0 * Math.Log(random.NextDouble()))) + mean;

This code generates a single random number with a mean of 0 and standard deviation of 1, using the Box-Muller transform to generate normally distributed numbers. The `NextDouble()` method is a built-in method of System.Random that generates a random number between 0 and 1.

Random random = new Random(); double[] values = new double[100]; for (int i = 0; i < values.Length; i++) { double mean = 10.0; double stddev = 2.0; double randomNumber = (stddev * random.NextDouble() * Math.Sqrt(-2.0 * Math.Log(random.NextDouble()))) + mean; values[i] = randomNumber; }This code generates an array of 100 random numbers with a mean of 10 and standard deviation of 2. It uses the same Box-Muller transform as

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related