-
Notifications
You must be signed in to change notification settings - Fork 74
6213 Шилина В.В. Лаб.2 Вар.21 #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
lab_2/tests.py
Outdated
| for i in range(0, len(sequence), 8): | ||
| block = sequence[i:i + 8] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
длина блока может быть и другой
посмотрите NIST 800-22
| s_n = abs(sequence.count('1') - sequence.count('0')) / math.sqrt(len(sequence)) | ||
| p_value = math.erfc(s_n / math.sqrt(2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить обработку исключений
| return 0.0 | ||
|
|
||
| v_n = sum(1 if sequence[i] != sequence[i + 1] else 0 for i in range(n - 1)) | ||
| p_value = math.erfc(abs(v_n - 2 * n * zeta * (1 - zeta)) / (2 * math.sqrt(2 * n) * zeta * (1 - zeta))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить обработку исключений
В лабораторной работе были сгенерированы случайные бинарные последовательности на языках C++ и Java, после чего на Python были проведены с этими последовательностями 3 теста NIST. В файле random.cpp находится генератор случайных последовательностей на языке C++, а в RandomGenerator.java на языке Java. Результаты сгенерированных последовательностей находятся в файлах sequence_сpp.txt и sequence_java.txt. В
tests.pyреализованы тесты NIST для определения меры случайности полученных последовательностей.Результаты тестов находятся в файле results.json. Так как у каждого теста результаты P-value > 0.01, то обе последовательности можно считать случайными.