Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonic Mean Calculation in Number Class #102

Closed
wants to merge 1 commit into from

Conversation

akr4m
Copy link

@akr4m akr4m commented Dec 1, 2023

This PR introduces a new feature to the Number class - the harmonize method. This method calculates the harmonic mean of a given set of numbers.

  • The harmonize method accepts an indefinite number of numeric arguments.
  • It throws an InvalidArgumentException if any argument is non-numeric or less than or equal to zero.
  • This method is particularly useful in scenarios where the average rates or ratios are required, like in financial applications, performance monitoring, or data analysis.

Example

// Example usage of the harmonize method
$averageSpeed = Number::harmonize(60, 40); // Average speed for two different speeds
echo "The harmonic mean of the speeds 60 and 40 is: " . $averageSpeed . " km/h"; // 48 km/h

// Another example with more numbers
$dataRates = Number::harmonize(5, 10, 15); // Harmonic mean of data transfer rates
echo "The harmonic mean of the data rates 5, 10, 15 is: " . $dataRates . " Mbps"; // 6.666666666666667 Mbps

Impact

  • This enhancement broadens the utility of the Number class, making it a more versatile tool for various mathematical and statistical calculations on Laravel applications.

Copy link

github-actions bot commented Dec 1, 2023

Thank you for your pull request. However, you have submitted this PR on the Illuminate organization which is a read-only sub split of laravel/framework. Please submit your PR on the https://github.com/laravel/framework repository.

Thanks!

@github-actions github-actions bot closed this Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant