rand

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Float64 = rand.Float64

Functions

func Const

func Const(seed ...uint64) func() float64

Const returns a sequence of numbers fixed by seeds.

Example
package main

import (
	"fmt"

	"github.com/itsubaki/q/math/rand"
)

func main() {
	c := rand.Const()
	fmt.Printf("%.13f\n", c())
	fmt.Printf("%.13f\n", c())
	fmt.Printf("%.13f\n", c())
	fmt.Printf("%.13f\n", rand.Const(1)())
	fmt.Printf("%.13f\n", rand.Const(1)())
	fmt.Printf("%.13f\n", rand.Const(1)())
	fmt.Printf("%.13f\n", rand.Const(2)())
	fmt.Printf("%.13f\n", rand.Const(3)())
	fmt.Printf("%.13f\n", rand.Const(1, 0)())
	fmt.Printf("%.13f\n", rand.Const(1, 1)())
	fmt.Printf("%.13f\n", rand.Const(1, 2)())

}
Output:

0.9999275824803
0.8856419373529
0.3814775277115
0.2384231908739
0.2384231908739
0.2384231908739
0.8269781200925
0.8353847703964
0.2384231908739
0.3402859786606
0.6764556596678

func Coprime

func Coprime(N int) int

Coprime returns a random coprime number in [2, N).

Example
package main

import (
	"fmt"

	"github.com/itsubaki/q/math/rand"
)

func main() {
	p := rand.Coprime(15)

	for _, e := range []int{2, 4, 7, 8, 11, 13, 14} {
		if p == e {
			fmt.Println("found")
			break
		}
	}

}
Output:

found

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL