SarthakKeshari / calc_for_everything

This repository aims to provide Calculators for educational, professional, scientific, health and well-being and other purposes.
https://calc-for-everything-psi.vercel.app
MIT License
113 stars 103 forks source link

Mean Deviation about the Median Calculator - (Issue #449) Fixed #515

Closed DeexithParand2k2 closed 10 months ago

DeexithParand2k2 commented 10 months ago

Issue I worked upon

Mean Deviation about the Median Calculator - (Issue #449) Fixed

Introduction

This open-source project provides a Mean Deviation about the Median Calculator, a tool to calculate the mean deviation about the median for a dataset with class intervals and frequencies. This readme explains the algorithm used to calculate the mean deviation about the median and highlights key features of the React component used for this calculator.

Issue #449: Algorithm Explanation

Step 1: Creating Cumulative Frequency Array

In this step, we create a cumulative frequency array (cf) to keep track of the cumulative frequencies of each class. We initialize cfsum with the first frequency and push it to the cf array. We then iterate through the frequencies and update cfsum to calculate cumulative frequencies.

Step 2: Calculating Required Values for Median

We calculate the total frequency N by taking the last value of the cf array. We also compute N/2 and store it as N_2.

Step 3: Finding and Getting Median Class

In this step, we find the median class. We iterate through the cumulative frequency array to find the first cumulative frequency that is greater than N/2. This identifies the median class.

Step 4: Getting Variables from Median Class

We extract key values from the median class, including:

Step 5: Finding Midpoint (|xi| Column)

We calculate the midpoint for each class interval and store it in an array called mid.

Step 6: Finding |xi - md| Column

We find the absolute difference between each midpoint and the calculated median value, storing the results in the mid_md_dist array.

Step 7: Finding Frequency * |xi - md| Column

We multiply the absolute differences (mid_md_dist) by their respective frequencies and store the results in the freq_dist array.

Step 8: Summing Up |xi - md| Column

We sum up the values in the freq_dist array to get the total sum of the absolute differences.

Step 9: Final Calculation

image

Finally, we calculate the mean deviation about the median (mean_deviation_abt_median) by dividing the sum of the absolute differences (freq_dist_sum) by the total frequency (N).

React Component Features

In the React component created for this calculator, you can find the following features:

  1. Editable Table: Users can input values for class intervals and frequencies, making it easy to work with different datasets.

  2. Input Validation: Input fields cannot be left empty; they will be filled with default zero values, ensuring data integrity.

  3. Table Management: The component provides options to add new rows, delete rows, and reset the table, enhancing the user experience and ease of data entry.

  4. Error Handling: Proper error handling is implemented to prevent the program from crashing due to invalid or incomplete input.

  5. Code Comments and JSDoc Annotations: The React code is thoroughly commented, and JSDoc annotations are used to provide clear documentation and improve code maintainability.

Screenshots of input and output -

Test 1

Screenshot (3637)

Test 2

Screenshot (3636)

Test 3

Screenshot (3635)


By raising this PR I affirm that -

DeexithParand2k2 commented 10 months ago

Hi @SarthakKeshari, I've completed the issue #449 and have raised a PR. Kindly review and merge my PR as soon as possible. Thanks for the opportunity.

SarthakKeshari commented 10 months ago

Congratulations šŸŽ‰ @DeexithParand2k2 on your contribution. Thanks for adding value to this repository. šŸ˜Š

Let's celebrate this fest šŸ˜ƒ by providing more developers šŸ‘Øā€šŸ’»šŸ‘©ā€šŸ’» an opportunity to contribute. Help us make this repository reach far and more by sharing this to your friends and colleagues.

Your efforts can make difference.

SarthakKeshari commented 10 months ago

Hey šŸ‘‹, may you also encourage us by clicking the star icon on the repository main page. ā­

image

SarthakKeshari commented 10 months ago

Thanks @DeexithParand2k2, For so detailed explanation.