You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
May be a good idea to keep random number generation predictable and independent. An example:
using Random
#=
Generate a stream of random bits.
Provide functions that convert a bit stream into a randomQAM symbol stream
=#
struct BitGenerator
rng::MersenneTwister
function BitGenerator(seed::UInt32)
rng = MersenneTwister(seed);
new(rng);
end
end
function genBits(bgen::BitGenerator, nbits::Int64)
buffer = rand(bgen.rng, [0,1], nbits);
end
function genBits!(bgen::BitGenerator, buffer::Vector{Int64})
buffer = rand!(bgen.rng, buffer, [0,1]);
end
bgen = BitGenerator(UInt32(12))
buffer = zeros(Int64, 12)
genBits!(bgen, buffer)
#=
12-element Vector{Int64}:
0
1
1
1
0
⋮
1
1
1
0
0
=#
The text was updated successfully, but these errors were encountered:
Hello,
Thanks for the feedback !
I am not really sure to understand your point. To have a bit stream generation in DigitalComm you have genBitSequence that takes a size N as input parameter and a seed, so it seems to be similar with what you point ? The seed is an optional parameter though, but this seems fine for me
In any ways we have:
using DigitalComm, Random
N = 512
seed = 1234
bitSeq = genBitSequence(N,seed)
bitSeq2 = genBitSequence(N,seed)
all(bitSeq .== bitSeq2) # returns true
But if I have understand at all what was your point, do not hesitate to tell :)
Thanks for replying. Maybe I have misunderstood whether the use of a seed within 'genBitSequence' will retain state on successive calls to that routine.
In the example I give above, the seed can be set initially and the state is maintained as per the last call so that successive calls progress the random number generator state. This means I can have several generators in the program, each able to create independent random streams that can be called within a loop.
May be a good idea to keep random number generation predictable and independent. An example:
The text was updated successfully, but these errors were encountered: