Closed DeexithParand2k2 closed 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.
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.
Thanks @DeexithParand2k2, For so detailed explanation.
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 initializecfsum
with the first frequency and push it to thecf
array. We then iterate through the frequencies and updatecfsum
to calculate cumulative frequencies.Step 2: Calculating Required Values for Median
We calculate the total frequency
N
by taking the last value of thecf
array. We also computeN/2
and store it asN_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:
median_l
: Lower limit of the median classmedian_f
: Frequency of the median classmedian_c
: Cumulative frequency just above the median classmedian_h
: The width (upper limit - lower limit) of the median classStep 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 thefreq_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
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:
Editable Table: Users can
input values
for class intervals and frequencies, making it easy to work with different datasets.Input Validation: Input fields cannot be left empty; they will be filled with
default zero values
, ensuring data integrity.Table Management: The component provides options to
add new rows
,delete rows
, andreset the table
, enhancing the user experience and ease of data entry.Error Handling: Proper error handling is implemented to prevent the program from crashing due to invalid or incomplete input.
Code Comments and JSDoc Annotations: The React code is thoroughly
commented
, andJSDoc annotations
are used to provide clear documentation and improve code maintainability.Screenshots of input and output -
Test 1
Test 2
Test 3
By raising this PR I affirm that -
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code.
[x] My code gives the correct output.
[x] I affirm that I strictly follow contributing guidelines and code of conduct.