-
Notifications
You must be signed in to change notification settings - Fork 74
6214 Цветков А.А. Лаб.2 Вар.22 #265
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
ISB_LAB_2/src/generate_java.java
Outdated
| public class RandomSequenceJava { | ||
| // Простой парсер для извлечения значения поля input_file_java из settings.json | ||
| public static String getInputFileJava(String filename) { | ||
| try { | ||
| // Читаем весь файл в строку | ||
| BufferedReader reader = new BufferedReader(new FileReader(filename)); | ||
| StringBuilder content = new StringBuilder(); | ||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| content.append(line.trim()); // Удаляем лишние пробелы и переносы строк |
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
| string getInputFileCpp(const string& filename) { | ||
| // парсер для извлечения значения поля input_file_cpp из settings.json | ||
| ifstream file(filename); | ||
| if (!file.is_open()) { | ||
| cerr << "Error: Could not open " << filename << "!" << endl; |
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.
аналогично для плюсов
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.
не исправлено
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.
почистить файлы
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.
не исправлено
ISB_LAB_2/main.py
Outdated
| """ | ||
| Returns: | ||
| 0 в случае успешного выполнения, 1 при возникновении ошибок. | ||
| """ | ||
| # Чтение settings.json |
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.
нет описания функции, исправьте docstring
ISB_LAB_2/tester.py
Outdated
| print(f"\nРезультаты тестов для {filename}:") | ||
| print(f"Частотный тест p-значение: {p1:.6f} {'(Passed)' if p1 >= 0.01 else '(Failed)'}") | ||
| print(f"Тест на серии p-значение: {p2:.6f} {'(Passed)' if p2 >= 0.01 else '(Failed)'}") | ||
| print(f"Тест на самую длинную серию p-значение: {p3:.6f} {'(Passed)' if p3 >= 0.01 else '(Failed)'}") No newline at end of file |
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.
сохранить результат в файл
ISB_LAB_2/tests.py
Outdated
| for bit in sequence: | ||
| sum_bits += 1 if bit == '1' else -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.
заменить цикл на однострочную функцию
ISB_LAB_2/tests.py
Outdated
| print(f"Тест на серии: Доля единиц ({pi:.6f}) слишком отклоняется. Тест не пройден.") | ||
| return 0.0 | ||
|
|
||
| runs = 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.
почему runs = 1?
ISB_LAB_2/tests.py
Outdated
| p-значение теста. | ||
| """ | ||
| #значение из методички | ||
| pi_values = [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.
вынести в файл с настройками
ISB_LAB_2/tests.py
Outdated
| m = 8 | ||
| N = 16 |
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.
никаких захардкоженных значений в коде быть не должно
ISB_LAB_2/tests.py
Outdated
|
|
||
| xi_square = sum(((v[i] - N * pi_values[i]) ** 2) / (N * pi_values[i]) for i in range(4)) | ||
|
|
||
| p_value = special.gammainc(3/2, xi_square/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.
проверьте функцию для вычисления p_value
| string getInputFileCpp(const string& filename) { | ||
| // парсер для извлечения значения поля input_file_cpp из settings.json | ||
| ifstream file(filename); | ||
| if (!file.is_open()) { | ||
| cerr << "Error: Could not open " << filename << "!" << endl; |
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.
не исправлено
| public static String getInputFileJava(String filename) { | ||
| try (BufferedReader reader = new BufferedReader(new FileReader(filename))) { | ||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| // Ищем строку содержащую input_file_java |
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
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.
не исправлено
| @@ -0,0 +1,98 @@ | |||
| import math | |||
| from scipy import special | |||
| from constants import SIZE_BLOCK, PI_VALUES, NUMBER_OF_BLOCKS | |||
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.
- файл с константами не является исполняемым
- этого модуля в данном пул-реквесте вообще нет
как у вас компилится код? - вынести константы в файл с настройками
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.
не исправлено
| @@ -0,0 +1,98 @@ | |||
| import math | |||
| from scipy import special | |||
| from constants import SIZE_BLOCK, PI_VALUES, NUMBER_OF_BLOCKS | |||
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++ генератор (src/generate_cpp.cpp):
Использует Mersenne Twister (std::mt19937) как ГПСЧ
Генерирует 128-битные последовательности
Сохраняет результат в файл, указанный в settings.json
Java генератор (src/generate_java.java):
Также создаёт 128-битные последовательности
Сохраняет результат в указанный файл
Файлы NIST тестов (tests.py, sequence_tester.py):
Реализует три основных статистических теста:
Частотный (побитный) тест - проверка баланса 0 и 1
Тест на серии - анализ чередований битов
Тест на длиннейшую серию - проверка максимальных последовательностей одинаковых битов
Сгенерированные последовательности находятся в папке /output
В файле result.txt содержится небольшой отчет о результатах тестов.
Файл с настройками: settings.json
Входная точка: main.py