Search found 80 matches

by Alex1
Sat Jun 24, 2023 11:30 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

All you have to do is test your final generator, the one you propose as the best. For example, I proposed only two algorithms: LFSR64+LCG64 and ACR4. Not all intermediate test algorithms need to be tested for as long, only the last one should be.
by Alex1
Sat Jun 24, 2023 9:13 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation


It's not looping, though. It fails random tests before looping. Imagine you have a simple 64 bit counter, it wouldn't be random, but it would still produce 2^64 unique outputs before looping.


My algorithms LFSR64+LCG64 or ARC4 remain random throughout the period because they are based on ...
by Alex1
Sat Jun 24, 2023 8:38 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

The main part is only 65 cycles. Did I win the fun challenge?

Not quite. My code produces 32 bits at a time, and it's only 80 cycles when you put all the variables in zero page, so that's 20 cycles/byte. On the other hand, the random quality of my output is considerably lower. For a real apples ...
by Alex1
Sat Jun 24, 2023 8:33 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

Arlet wrote:
Alex1 wrote:
If I want to go back to the beginning and get the same random byte string, just make a call to init:. Without this initialization function, once the algorithm is launched, I can't start over at the beginning.
Shouldn't you also restore your 'array' contents ?
Indeed, corrected !
by Alex1
Fri Jun 23, 2023 3:12 pm
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation


I'm curious why you need the 'init' procedure at all. The values in 'storex' and 'storey' are fixed at assembly time, and the values do not change thereafter. You apparently do nothing with the return value from 'init' (which only loads the Y-register and then does nothing with it. Is that ...
by Alex1
Fri Jun 23, 2023 10:44 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

The atarisim code is :

It can be compiled with :

cl65 -tatari -Catari-asm.cfg 1995prng.asm


and can be run with :


./atarisim 1995prng | xxd -r -p | rng_test stdin8




.export start
ICPTL = $0346
ICPTH = $0347

.zeropage
zp_start:
cnt: .res 6
zp_end:

.code

.proc init

init:
ldx ...
by Alex1
Fri Jun 23, 2023 10:39 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

The main part is only 65 cycles. Did I win the fun challenge?


ldx storex -- 4 cycles
inx -- 2 cycles
lda array,x -- 5 cycles
pha -- 3 cycles
clc -- 2 cycles
adc storey -- 4 cycles
sta storey -- 4 cycles
ldy storey -- 4 cycles
lda array,y -- 5 cycles
sta array,x -- 5 cycles
pla -- 4 cycles ...
by Alex1
Fri Jun 23, 2023 10:37 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

Here is my 1995 PRNG code :

call Init: one time
each time you want a random byte, call begin:
the random byte is in rndbyte.

The period before repetition is factorial 256 : !(256)



// Random Generator 1995

//----------------------------------------------------
// Main Program ...
by Alex1
Fri Jun 23, 2023 10:32 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation


It's simply a fun challenge to produce a certain result in minimum number of cycles , that may be useful to some people. Part of the challenge is to work within the limitations of the chosen target.

Ok if the challenge is to use the minimum number of cycles, i notice that Arlet's last ...
by Alex1
Tue Jun 20, 2023 7:38 am
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

By the way my LFSR64+LCG64 still good after 16TB data...

RNG_test using PractRand version 0.94
RNG = RNG_stdin8, seed = unknown
test set = core, folding = standard (8 bit)

rng=RNG_stdin8, seed=unknown
length= 8 megabytes (2^23 bytes), time= 2.9 seconds
no anomalies in 76 test result(s)

rng=RNG ...
by Alex1
Thu Jun 01, 2023 1:45 pm
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

a few other random generators :

batari8 (0)
Type: galois8 lfsr
6502 author: Fred Quimby
RAM: 1 byte
Size: 9 bytes
Cycles: 11-12
Period: 255
References: https://github.com/batari-Basic
Notes: This is the rand routine included with the 2600 development
language batari Basic. It's main ...
by Alex1
Tue May 16, 2023 1:30 pm
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

looking over it more, there are the xor of a LFSR, and these incremented steps, like you are moving the frame of the XOR rather than moving the contents

LFSRs have been studied mathematically so that there is no short cycle, if you change the XOR of an LFSR, you will get short cycles.

By the way ...
by Alex1
Sat Apr 22, 2023 10:45 pm
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

Practrand is a bad tester of random number generator on large data sets.The more data there is to test, the less it detects things.

Here is the test i did.

I created a 8GB file with all 0x00:

8 GB
8 589 934 592 bytes

I encrypted this file with AES 128 and a random key.

I encrypted this result ...
by Alex1
Fri Apr 21, 2023 6:51 pm
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation

Arlet, you conclude that practrand is not good on 1 KB sets but there is no warning in the README file. If it's not good on 1kb why would it be good on a larger dataset.
We would have to find another tester than Practrand. He cannot be trusted. It's not clear if it's good on large data sets where it ...
by Alex1
Fri Apr 21, 2023 3:42 pm
Forum: Programming
Topic: Random-number generation
Replies: 246
Views: 79015

Re: Random-number generation


Here are 3 random files generated with AES-128 CBC Mode.

All files pass the 1kb test without errors.

Now try with 100 files.
There you would like to do 100 tests of 1 kb on existing algorithms and compare the number of FAIL with yours? you think it's reliable as a method of testing a PRNG ...