-
Notifications
You must be signed in to change notification settings - Fork 74
6214 Носов И.С. Лаб.2 Вар.13 #223
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/NIST_tests/NIST_tests.py
Outdated
| :param sequence: бинарная последовательность | ||
| :return: P-значение последовательности | ||
| """ | ||
| p = [0.2148, 0.3672, 0.2305, 0.1875] |
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.
вынести в файл с настройками
lab_2/NIST_tests/NIST_tests.py
Outdated
| p = [0.2148, 0.3672, 0.2305, 0.1875] | ||
| v = [0, 0, 0, 0] | ||
| n = len(sequence) | ||
| for i in range(0, n, 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.
длину блока вынести в файл с настройками
lab_2/NIST_tests/NIST_tests.py
Outdated
| if max_length <= 1: | ||
| v[0] += 1 | ||
| elif max_length == 2: | ||
| v[1] += 1 | ||
| elif max_length == 3: | ||
| v[2] += 1 | ||
| else: | ||
| v[3] += 1 |
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.
использовать match/case
|
|
||
| public class Random128Bit { | ||
| public static void main(String[] args) { | ||
| Random random = new Random(); | ||
| byte[] bytes = new byte[16]; // 16 bytes = 128 bits | ||
| random.nextBytes(bytes); |
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.
В java есть JavaDoc
https://docs.oracle.com/en/java/javase/23/docs/specs/man/javadoc.html
| #include <iostream> | ||
| #include <bitset> | ||
|
|
||
| int main() { | ||
| std::random_device rd; | ||
| std::mt19937_64 gen(rd()); | ||
| uint64_t high = gen(); |
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++ тоже есть стандарт описания функций
Было необходимо сгенерировать 2 случайные последовательности с помощью генераторов псевдослучайных чисел и проверить их с помощью тестов NIST. В папке random содержится код для 1-го задания, в папке NIST_tests - для 2-го.
В модуле files_work.py находятся функции для работы с json и txt файлами. Модуль main.py является точкой входа в программу и содержит в себе все необходимые вызовы функций, необходимые для выполнения задания
P-value:
Частотный побитовый тест: 0.5958830905651779
Тест на одинаковые подряд идущие биты: 0.03563414199903021
Тест на самую длинную последовательность единиц в блоке: 0.9999999999999941
Частотный побитовый тест: 0.11161176829829222
Тест на одинаковые подряд идущие биты: 0.007878283878835393
Тест на самую длинную последовательность единиц в блоке: 0.9999999999999941
Последовательности плохо прошли тест на одинаковые подряд идущие символы, поэтому последовательность на java не является случайной, а последовательность на c++ является