Skip to content

ppnpp123/reverse_mean_calculate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Reverse Mean Calculator / 逆推计算器

English | 中文


English

Introduction

Reverse Mean Calculator is a Python-based GUI application that allows you to generate a set of random integers that satisfy specific statistical properties:

  1. The mean (average) of the numbers is exactly equal to a target value.
  2. The range (difference between maximum and minimum) does not exceed 10.

This tool is useful for generating test data or simulating scenarios where the average is known but the individual data points need to be reconstructed within a tight distribution.

Features

  • Precise Mean: The generated numbers sum up to Mean * Count exactly.
  • Controlled Variance: The spread of numbers is constrained (Max - Min ≤ 10).
  • User-Friendly GUI: Built with tkinter, providing a simple interface for input and verification.
  • Standalone Executable: Can be built into a single .exe file for Windows.

Usage

  1. Run the Application:
    • If using the source code: python reverse_mean_gui.py
    • If using the executable: Double-click ReverseMeanCalculator.exe
  2. Input Parameters:
    • Target Mean (x): The desired average value (e.g., 80).
    • Count (n): The number of integers to generate (e.g., 5).
  3. Generate: Click the "Generate" button.
  4. Verify: The result area will show the generated numbers along with verification stats (Sum, Mean, Range).

Building from Source

To compile the application into an executable:

  1. Ensure you have Python installed.
  2. Run the build script:
    python build.py
    This will handle dependencies (installing pyinstaller if needed) and generate the .exe in the dist/ folder.

中文

简介

逆推计算器 (Reverse Mean Calculator) 是一款基于 Python 的 GUI 应用程序,用于生成满足特定统计特性的一组随机整数:

  1. 这些数字的均值严格等于指定的目标值。
  2. 这些数字的极差(最大值与最小值的差)不超过 10。

该工具适用于需要根据已知均值反推数据点,且要求数据分布紧凑的场景(如模拟打分、生成测试数据等)。

功能特点

  • 均值精确:生成的数字总和严格等于 均值 × 数量
  • 波动可控:数据分布集中,保证最大值与最小值的差 ≤ 10。
  • 界面友好:基于 tkinter 开发,操作简单直观,自带结果验证功能。
  • 独立运行:可打包为 Windows 下的独立 .exe 文件,无需安装 Python 环境。

使用方法

  1. 运行程序
    • 源码运行:python reverse_mean_gui.py
    • 可执行文件:双击 ReverseMeanCalculator.exe
  2. 输入参数
    • 目标均值 (x):期望的平均值(例如 80)。
    • 数量 (n):需要生成的整数个数(例如 5)。
  3. 生成结果:点击“生成结果”按钮。
  4. 查看验证:结果区域将显示生成的数字列表,以及自动计算的总和、均值和极差,方便核对。

源码编译

如果您需要将源码打包为可执行文件:

  1. 确保已安装 Python。
  2. 运行构建脚本:
    python build.py
    脚本会自动检查依赖(如 pyinstaller)并在 dist/ 目录下生成 .exe 文件。

About

给定均值,逆推样本值。reverse_mean_calculate

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages