InsaneMonster / NistRng

Random Number Generator NIST Test Suite framework for python 3.6 - SAILab - University of Siena
BSD 3-Clause "New" or "Revised" License
42 stars 22 forks source link

Some bug I found in this project #10

Open Scottyang8math opened 2 years ago

Scottyang8math commented 2 years ago

Recently, I have used this project in my research. There are two bugs I found. First: it seems to change the original sequences after running the "binary_matrix_rank" test. It should be fixed by replacing "self._matrix = block" with "self._matrix = block.copy()" on line 31 of file "test_binary_matrix_rank.py".

lastly: As @Programmer101N mentioned, it has the wrong output for the "Random Excursion Test". It should be fixed by the following change: line 64,65:

         if sum_prime[index] != 0:
            cycle += [sum_prime[index]]

        if sum_prime[index + 1] != 0:
            cycle += [sum_prime[index + 1]]

line 71:

    cycles.append(cycle)

    # cycles.append(cycle)

line 86--98 replaced by (Important)

    # Count occurrences
    for value in frequencies_table.keys():
        for cycle in cycles:
            occurrences: int = numpy.count_nonzero(numpy.array(cycle) == value)
            if occurrences > 5:
                occurrences = 5
            frequencies_table[value][occurrences] += 1

(In fact, I did not understand the original code. This code is what I understand of "ν_k (x)" on Page 2-36 of the official document.)

Thanks for this project!

jeste76 commented 2 years ago

Hi Scottyang8math,

did you publish your changed version somewhere on github? I'd love to use the corrected version of the tests in my projects.

zazuza7 commented 1 year ago

I created a fork where I implemented @Scottyang8math suggestions https://github.com/zazuza7/NistRng