Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wambita/math-skills
A program that calculates the following from a data set Average, Median, Variance, Standard Deviation
https://github.com/wambita/math-skills
Last synced: 6 days ago
JSON representation
A program that calculates the following from a data set Average, Median, Variance, Standard Deviation
- Host: GitHub
- URL: https://github.com/wambita/math-skills
- Owner: Wambita
- License: mit
- Created: 2024-05-08T15:48:19.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-06-03T07:32:38.000Z (8 months ago)
- Last Synced: 2024-12-05T09:14:33.870Z (2 months ago)
- Language: Go
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MATH-SKILLS
## Overview
This Go program calculates essential statistical measures such as Average, Median, Variance, and Standard Deviation from a dataset provided in a text file. Each line of the file represents an individual data point of a statistical population.### Instructions
The program reads from a file and print the result of each statistic . The program reads the data present in the path passed as argument. The data in the file will be presented as the following example:
```
189
113
121
114
145
110
...
```This data represents a statistical population: each line contains one value.
## Features
- **Reads data from a file**: The program reads numbers from a file where each line contains one numerical data point.
- **Calculates Statistical Measures**:
- **Average**: Computes the mean of the dataset.
- **Median**: Determines the middle value of the dataset.
- **Variance**: Calculates the measure of the spread of numbers in the dataset.
- **Standard Deviation**: Computes the dispersion of the dataset from the mean.
- **Outputs Rounded Results**: All results are rounded to the nearest integer and printed to the console.## Prerequisites
You need to have Go installed on your system to run this program. Go can be downloaded from [https://golang.org/dl/](https://golang.org/dl/).## Setup
To set up the project on your local machine, follow these steps:```bash
git clone https://learn.zone01kisumu.ke/git/shfana/math-skills
cd math-skills
```
# UsageTo run the program, you will pass the path of the data file as a command-line argument. For example:
```bash
go run main.go data.txt
```
This command will process the numbers in data.txt, compute the required statistical measures, and output them rounded to the nearest integer as shown below:```bash
Average:
Median:
Variance:
Standard Deviation:
```
## Testing### Overview
Tests are organized to validate each statistical function in the mathskills package. This ensures accuracy and robustness of the computations.
Running TestsExecute the following command in the terminal to run all tests:
```bash
go test -v ./mathskills/...
```
To run tests for a specific function:
```bash
go test -v ./mathskills/average_test.go
```Expected Test Output
Successful test execution will display:
```diff
=== RUN TestCalcAverage
--- PASS: TestCalcAverage (0.00s)
=== RUN TestCalcMedian
--- PASS: TestCalcMedian (0.00s)
=== RUN TestCalcVariance
--- PASS: TestCalcVariance (0.00s)
=== RUN TestCalcStdDev
--- PASS: TestCalcStdDev (0.00s)
PASS
ok mathskills 0.005s
```
### Learning Outcomes- Statistics and Mathematics: Understanding and applying basic statistical calculations.
- File Handling in Go: Reading and processing data effectively using Go.
- Robust Go Programming: Implementing and testing reliable Go programs.### Contributions
Contributions are welcome. Please ensure your code adheres to the existing style and includes tests where applicable.
## License
This project is protected under the MIT Licence. See the [license](LICENSE) for details## Author
This project was created by [shfana](https://github.com/Wambita)