Skip to content

randn() and BigFloat #27858

@AshtonSBradley

Description

@AshtonSBradley

In the docs:

https://docs.julialang.org/en/latest/stdlib/Random/

A MersenneTwister or RandomDevice RNG can generate random numbers of the following types: Float16, Float32, Float64, BigFloat, Bool, Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128, BigInt (or complex numbers of those types). Random floating point numbers are generated uniformly in [0,1). As BigInt represents unbounded integers, the interval must be specified (e.g. rand(big.(1:6))).

However,

julia> randn(BigFloat)
ERROR: MethodError: no method matching randn(::MersenneTwister, ::Type{BigFloat})
Closest candidates are:
  randn(::AbstractRNG, ::Type{T}, ::Tuple{Vararg{Int64,N}} where N) where T at random.jl:1387
  randn(::AbstractRNG, ::Type{T}, ::Integer, ::Integer...) where T at random.jl:1389
  randn(::AbstractRNG) at random.jl:1257
  ...
Stacktrace:
 [1] randn(::Type{BigFloat}) at ./random.jl:1374

Is there some special syntax to call randn() for BigFloat? Is it supported?

Metadata

Metadata

Assignees

Labels

docsThis change adds or pertains to documentationrandomnessRandom number generation and the Random stdlib

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions