Programming Language: Golang

Namespace/Package Name: math/rand

Class/Type: Rand

Method/Function: NormFloat64

Examples at hotexamples.com: 30

The math/rand package in Go provides a source of pseudorandom numbers using various algorithms. One of the functions provided by this package is Rand NormFloat64, which generates normally distributed pseudorandom numbers with a mean of 0 and a standard deviation of 1.

Example:

Example:

package main import ( "fmt" "math/rand" ) func main() { // Generate a single normally distributed random number n := rand.NormFloat64() fmt.Printf("Generated number: %f\n", n) // Generate ten normally distributed random numbers for i := 0; i < 10; i++ { n := rand.NormFloat64() fmt.Printf("Generated number %d: %f\n", i+1, n) } }In this example, we import the math/rand package and use the Rand NormFloat64 function to generate normally distributed random numbers. The first example generates a single random number and prints it to the console. The second example generates ten random numbers and prints each one along with a label indicating its order. The math/rand package is part of the standard library in Go.

Frequently Used Methods

Frequently Used Methods

Related

Related in langs