Skip to content

Conversation

@avof1ow
Copy link

@avof1ow avof1ow commented Sep 19, 2025

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

@github-actions github-actions bot added In progress Код в процессе проверки Lab 2 Лабораторная 2 "Статистический анализ псевдослучайных последовательностей" labels Sep 19, 2025
Comment on lines 8 to 17
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()); // Удаляем лишние пробелы и переносы строк

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 9 to 13
string getInputFileCpp(const string& filename) {
// парсер для извлечения значения поля input_file_cpp из settings.json
ifstream file(filename);
if (!file.is_open()) {
cerr << "Error: Could not open " << filename << "!" << endl;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

аналогично для плюсов

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не исправлено

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почистить файлы

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не исправлено

Comment on lines 6 to 10
"""
Returns:
0 в случае успешного выполнения, 1 при возникновении ошибок.
"""
# Чтение settings.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет описания функции, исправьте docstring

Comment on lines 29 to 32
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сохранить результат в файл

Comment on lines 17 to 18
for bit in sequence:
sum_bits += 1 if bit == '1' else -1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

заменить цикл на однострочную функцию

print(f"Тест на серии: Доля единиц ({pi:.6f}) слишком отклоняется. Тест не пройден.")
return 0.0

runs = 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему runs = 1?

p-значение теста.
"""
#значение из методички
pi_values = [0.2148, 0.3672, 0.2305, 0.1875]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынести в файл с настройками

Comment on lines 69 to 70
m = 8
N = 16

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

никаких захардкоженных значений в коде быть не должно


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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверьте функцию для вычисления p_value

Comment on lines 9 to 13
string getInputFileCpp(const string& filename) {
// парсер для извлечения значения поля input_file_cpp из settings.json
ifstream file(filename);
if (!file.is_open()) {
cerr << "Error: Could not open " << filename << "!" << endl;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не исправлено

Comment on lines +1 to +5
public static String getInputFileJava(String filename) {
try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
String line;
while ((line = reader.readLine()) != null) {
// Ищем строку содержащую input_file_java

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. файл с константами не является исполняемым
  2. этого модуля в данном пул-реквесте вообще нет
    как у вас компилится код?
  3. вынести константы в файл с настройками

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не исправлено

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In progress Код в процессе проверки Lab 2 Лабораторная 2 "Статистический анализ псевдослучайных последовательностей"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants