Questions tagged [lcg]

A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation.

The linear congruential generator LCG is defined by recurrence relation:

    equation

where:
    X is the sequence of pseudo-random values
    m is the modulus (m > 0)
    a is the multiplier (0 < a < m)
    c is the increment (0 <= c < m)
    X0 is the "seed" or start value (0 <= X0 < m)

45 questions
2
votes
0 answers

LCG code in matlab

I have written this code : for i=1:m-1 x(i+1)=mod(a*x(i)+c,m) x(i)=x(i+1) end But I don't know how to write lcg as a function that generates random numbers. LCG is a linear congruential generator which is one of the oldest and best-known…
J.Bea
  • 51
  • 1
  • 3
2
votes
1 answer

Choose a, c, m in Linear Congruential Generator

I am looking to implement a linear congruential generator in Excel. As we know, we must choose the parameter of LCG is a, c, m, and Z0. Wikipedia says that The period of a general LCG is at most m, and for some choices of factor a much less than…
Elra Ghifary
  • 113
  • 1
  • 14
1
vote
1 answer

How to print table in looping pyhton console

I want to print a table on my console. From now am using pandas how to print using tabulate Here is my Source code: from numpy import average import pandas as pd z = 10119011 a = 17 c = 43 m = 499 for i in range(0, 21): LCG = ((a*z)+c) % m …
1
vote
0 answers

Random Number Generation via Linear Congruential Generators in C++

I am studying random number generation in C++ and I had implemented it from the following site: https://www.quantstart.com/articles/Random-Number-Generation-via-Linear-Congruential-Generators-in-C/ When running this program, I am getting the…
1
vote
1 answer

linear congruential generator using python to generate keystream and encrypt and decrypt the plaintext

I am making using linear congruential generator to generate the keystream and then I will use this keystream to encrypt and decrypt the plaintext.I am trying to generate 47 pseudorandom number the Plaintext will be…
1
vote
1 answer

Linear congruential generator - weak tests results

I'm trying to do the Dieharder Suite tests on my linear congruential generator. I am not sure if the tests are performed on my generator or simply the results are so weak. I generate 2,5 mio lines with the generator save them to file testrands.txt…
tbone
  • 1,148
  • 5
  • 19
  • 35
1
vote
1 answer

Dieharder random test suite - suspiciously good results

I generated a txt file based on the following generator (2500000 numbers) import numpy as np class LCG(object): UZERO: np.uint32 = np.uint32(0) UONE : np.uint32 = np.uint32(1) def __init__(self, seed: np.uint32, a: np.uint32, c:…
tbone
  • 1,148
  • 5
  • 19
  • 35
1
vote
0 answers

Given a pseudo-random number sequence, find the equivalent lcg generated one

Given a pseudo-random number sequence S, is there an equivalent lcg (linear congruential generator) generated sequence S' that respects the relative order of S, and if so is it possible to compute the parameters a, c, m and seed? For example, the…
0
votes
1 answer

LCG in MatLab implementation

hi im having trouble creating a linear congruential generator in MatLab, the ones that I found online work quite different than mine. then im trying to print values of the m and a (relatively prime, m being a large prime obviously) and check when…
0
votes
1 answer

How do I use an lcg "non-sequentially"

I want to create a game that is a 2d dungeon, each tile in the dungeon will have the same chance of being a solid or air block, the dungeon will be infinite and every time you spawn a dungeon it will be with a seed, same seed, same dungeon. Thinking…
0
votes
1 answer

How can I made a "non sequential" Random Number Generator LCG?

I recently created a RNG LCG, the formula is: newSeed = (131173 * actualSeed + 27) % 262144; But I have a question, this RNG is used to introduce a single seed and then it will generate a sequence. But I, for other reasons, need to introduce a seed…
user19894515
0
votes
0 answers

Linear Congruential generator graph

I implemented a simple code for a linear congruential generator clear all; clc % Input m = 59; % module a = 17; % multiplier c = 43; % increase X0 = 27; % seed n = 100; % sample length y = [X0…
SimoPape
  • 13
  • 2
0
votes
1 answer

Reverse multiplication with unknown dx - solve for original AX after multiple mul/add constant steps

I have this repeating iterative process in 16-bit x86 asm rec_loop: mul bx ; constant value of 0x11bf add ax, 0x4743 loop rec_loop it's running several times but for our case let's say it runs 3 times, now after it is finished I get…
Ido Sharon
  • 11
  • 2
0
votes
0 answers

Recommended value for the variable for Linear Congruential Generator

I am trying to generate 48 pseudoraandom number by using linear congruential generator. I am only using alphabet from a to z for my plaintext which will be for mapping 0 to 25. I am using the algorithm for the linear congruential generator…
0
votes
0 answers

How to implement a linear congruential generator in Java?

I am implementing my own PRNG where I should use the linear congruential generator. One of my methods should generate the next pseudo random number as seen below. The seed is retrieved from the user earlier. MyRandom(long seed) { Random random =…
Oscar00
  • 1
  • 1