Python/maths
Grigoriy Hanin 40e357f688
Mistake in maths/average_mode.py fixed. (#4464)
A serious bug was addressed with this pull request. The mode function previously
didn't return the mode of the input list. Instead, it always returned the first value.
Due to lacking tests, the bug was never caught. This pull request also adds new
functionality to the function, allowing support for more than one mode.

See #4464 for details.

* * Mistake in average_mode.py fixed. The previous solution was to returnthe
value on the first loop iteration, which is not correct, more than that it
used to delete repeating values, so result's array and check array lost
relation between each other

* Type hint added

* redundant check_list deleted

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Suggestions resolved

* output typing changed to Any
* test cases added

* Black done

File formatted

* Unused statistics import

statistics only used in doctest, now they are imported in doctest

* Several modes support added

Several modes support added

* Comment fix

* Update maths/average_mode.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Suggestions added

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
2021-06-04 15:16:32 -05:00
..
images Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
series Add arithmetic_mean.py (#4243) 2021-03-12 08:25:54 +01:00
__init__.py pyupgrade --py37-plus **/*.py (#1654) 2020-01-03 22:25:36 +08:00
3n_plus_1.py Change occurrences of str.format to f-strings (#4118) 2021-02-23 11:23:49 +05:30
abs_max.py from __future__ import annotations (#2464) 2020-09-23 13:30:13 +02:00
abs_min.py psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
abs.py some pytest on math folder (#1405) 2019-10-21 22:36:33 +02:00
add.py Rename math/add.py to maths/add.py (#1857) 2020-04-13 07:50:46 +02:00
aliquot_sum.py Optimization and fix bug (#2342) 2020-08-21 14:39:03 +08:00
allocation_number.py Fixed allocation_number (#2768) 2020-10-05 09:17:46 +05:30
area_under_curve.py codespell --quiet-level=2 (#1711) 2020-01-24 00:21:51 +08:00
area.py Add function to calculate area of triangle using Heron's formula (#4065) 2020-12-28 13:36:57 +05:30
armstrong_numbers.py Armstrong number definition fix (#4466) 2021-05-30 18:41:07 -05:00
average_mean.py some pytest on math folder (#1405) 2019-10-21 22:36:33 +02:00
average_median.py Optimization and fix bug (#2342) 2020-08-21 14:39:03 +08:00
average_mode.py Mistake in maths/average_mode.py fixed. (#4464) 2021-06-04 15:16:32 -05:00
bailey_borwein_plouffe.py refactor: Remove default value of exponential_term (#4308) 2021-04-04 09:32:36 +05:30
basic_maths.py contribution guidelines checks (#1787) 2020-03-04 13:40:28 +01:00
binary_exp_mod.py Added binary exponentiaion with respect to modulo (#1428) 2019-12-24 07:23:15 +01:00
binary_exponentiation_2.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
binary_exponentiation_3.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
binary_exponentiation.py Improved readability (#1615) 2019-12-07 06:39:59 +01:00
binomial_coefficient.py Added binomial coefficient (#1467) 2019-10-26 11:18:28 +02:00
binomial_distribution.py Added a binomial distribution formula calculator algorithm (#2197) 2020-07-13 22:18:37 +02:00
bisection.py Fixes black failures from Previous PR (#1751) 2020-02-13 02:19:41 +05:30
ceil.py Update ceil and floor function (#3710) 2020-10-26 00:02:24 +08:00
chudnovsky_algorithm.py Fix some warnings from LGTM (#2420) 2020-09-13 10:11:27 +02:00
collatz_sequence.py from __future__ import annotations (#2464) 2020-09-23 13:30:13 +02:00
combinations.py Made improvements to combinations.py (#3681) 2020-10-26 14:48:06 +08:00
decimal_isolate.py Added decimal_isolate.py (#3700) 2020-10-30 23:10:44 +01:00
entropy.py Pyupgrade to python3.8 (#3616) 2020-10-21 12:46:14 +02:00
euclidean_distance.py Create euclidean_distance.py (#3350) 2020-11-27 15:48:20 +01:00
euclidean_gcd.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
euler_method.py refactor: Rename explicit_euler.py to euler_method.py (#4275) 2021-03-20 11:41:10 +05:30
eulers_totient.py Code for Eulers Totient function (#1229) 2019-12-01 06:58:25 +01:00
extended_euclidean_algorithm.py Fixes: #2630 Add doctests and support for negative numbers (#2626) 2020-10-07 15:23:14 +05:30
factorial_iterative.py contribution guidelines checks (#1787) 2020-03-04 13:40:28 +01:00
factorial_python.py GitHub Action formats our code with psf/black (#1569) 2019-11-14 19:59:43 +01:00
factorial_recursive.py Create factorial_iterative.py (#1693) 2020-01-18 14:06:48 +01:00
factors.py Factors of a number (#1493) 2019-10-29 23:54:30 +01:00
fermat_little_theorem.py Set the Python file maximum line length to 88 characters (#2122) 2020-06-16 10:09:19 +02:00
fibonacci_sequence_recursion.py Added type hints for maths/fibonacci_sequence_recursion. (#2372) 2020-08-30 10:51:45 +02:00
fibonacci.py isort --profile black . (#2181) 2020-07-06 09:44:19 +02:00
find_max_recursion.py Tighten up psf/black and flake8 (#2024) 2020-05-22 08:10:11 +02:00
find_max.py rename and add doctest (#1501) 2019-10-28 13:50:36 +01:00
find_min_recursion.py Divide and Conquer (#1308) 2019-10-18 06:20:36 +02:00
find_min.py Update find_min.py (#1627) 2019-12-11 07:57:08 +01:00
floor.py Update ceil and floor function (#3710) 2020-10-26 00:02:24 +08:00
gamma.py isort --profile black . (#2181) 2020-07-06 09:44:19 +02:00
gaussian.py Correcting the Gaussian Formula (#2249) 2020-07-29 21:32:36 +02:00
greatest_common_divisor.py math/greatest_common_divisor: add support for negative numbers (#2628) 2020-10-29 12:47:26 +05:30
greedy_coin_change.py feat: Add greedy_coin_change.py algorithm (#3805) 2021-03-20 11:48:38 +05:30
hardy_ramanujanalgo.py pyupgrade --py37-plus **/*.py (#1654) 2020-01-03 22:25:36 +08:00
integration_by_simpson_approx.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
is_square_free.py from __future__ import annotations (#2464) 2020-09-23 13:30:13 +02:00
jaccard_similarity.py adding jaccard similarity (#1270) 2019-10-04 09:59:45 +02:00
kadanes.py Fix astar (#1966) 2020-05-10 20:49:40 +05:30
karatsuba.py psf/black code formatting (#1421) 2019-10-22 19:13:48 +02:00
krishnamurthy_number.py Python Program to Check Krishnamurthy Number (#2248) 2020-07-29 10:54:05 +02:00
kth_lexicographic_permutation.py Optimized recursive_bubble_sort (#2410) 2020-09-10 10:31:26 +02:00
largest_of_very_large_numbers.py LargestOfVeryLargeNumbers (#818) 2019-07-30 08:47:54 +02:00
largest_subarray_sum.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
least_common_multiple.py More efficient least common multiple. (#2281) 2020-08-05 12:39:15 +02:00
line_length.py from __future__ import annotations (#2464) 2020-09-23 13:30:13 +02:00
lucas_lehmer_primality_test.py Set the Python file maximum line length to 88 characters (#2122) 2020-06-16 10:09:19 +02:00
lucas_series.py Fixed LGTM and typehint (#3970) 2020-11-28 22:42:30 +08:00
matrix_exponentiation.py Set the Python file maximum line length to 88 characters (#2122) 2020-06-16 10:09:19 +02:00
max_sum_sliding_window.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
median_of_two_arrays.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
miller_rabin.py Added binary exponentiaion with respect to modulo (#1428) 2019-12-24 07:23:15 +01:00
mobius_function.py isort --profile black . (#2181) 2020-07-06 09:44:19 +02:00
modular_exponential.py Set the Python file maximum line length to 88 characters (#2122) 2020-06-16 10:09:19 +02:00
monte_carlo_dice.py fix(ci): Update pre-commit hooks and apply new black (#4359) 2021-04-26 07:46:50 +02:00
monte_carlo.py Tighten up psf/black and flake8 (#2024) 2020-05-22 08:10:11 +02:00
newton_raphson.py Optimized recursive_bubble_sort (#2410) 2020-09-10 10:31:26 +02:00
number_of_digits.py fix number_of_digits bug (#2301) 2020-08-12 18:32:35 +02:00
numerical_integration.py Pyupgrade to python3.8 (#3616) 2020-10-21 12:46:14 +02:00
perfect_cube.py Fix syntax for flake8 passing (#2096) 2020-06-12 06:51:47 +02:00
perfect_number.py Python Program to Check Krishnamurthy Number (#2248) 2020-07-29 10:54:05 +02:00
perfect_square.py Perfect square using binary search (#2351) 2020-08-25 21:26:11 +02:00
pi_monte_carlo_estimation.py Wrap lines that go beyond GitHub Editor (#1925) 2020-05-01 23:36:35 +02:00
polynomial_evaluation.py Update our pre-commit dependencies (#4273) 2021-03-20 10:42:17 +05:30
power_using_recursion.py Added Finding Exponent Program (#2238) 2020-07-27 11:33:13 +02:00
prime_check.py Improved and shortened prime_check.py (#3454) 2020-10-24 00:17:29 +08:00
prime_factors.py from __future__ import annotations (#2464) 2020-09-23 13:30:13 +02:00
prime_numbers.py isort --profile black . (#2181) 2020-07-06 09:44:19 +02:00
prime_sieve_eratosthenes.py Fix all errors mentioned in pre-commit run (#2512) 2020-09-30 10:38:00 +02:00
primelib.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
pythagoras.py pyupgrade --py37-plus **/*.py (#1654) 2020-01-03 22:25:36 +08:00
qr_decomposition.py psf/black code formatting (#1421) 2019-10-22 19:13:48 +02:00
quadratic_equations_complex_numbers.py Change occurrences of str.format to f-strings (#4118) 2021-02-23 11:23:49 +05:30
radians.py Tighten up psf/black and flake8 (#2024) 2020-05-22 08:10:11 +02:00
radix2_fft.py Tighten up psf/black and flake8 (#2024) 2020-05-22 08:10:11 +02:00
relu.py from __future__ import annotations (#2464) 2020-09-23 13:30:13 +02:00
runge_kutta.py psf/black code formatting (#1421) 2019-10-22 19:13:48 +02:00
segmented_sieve.py psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
sieve_of_eratosthenes.py [mypy] math/sieve_of_eratosthenes: Add type hints (#2627) 2020-11-23 11:07:42 +05:30
sigmoid.py Add Maths / Sigmoid Function (#3880) 2020-11-15 09:14:40 +05:30
simpson_rule.py Create codespell.yml (#1698) 2020-01-18 13:24:33 +01:00
softmax.py Optimized recursive_bubble_sort (#2410) 2020-09-10 10:31:26 +02:00
square_root.py Set the Python file maximum line length to 88 characters (#2122) 2020-06-16 10:09:19 +02:00
sum_of_arithmetic_series.py Add GitHub action for pre-commit (#2515) 2020-09-30 15:23:34 +02:00
sum_of_digits.py Update sum_of_digits.py (#2319) 2020-08-16 20:31:06 +02:00
sum_of_geometric_progression.py Optimized recursive_bubble_sort (#2410) 2020-09-10 10:31:26 +02:00
test_prime_check.py Add maths/test_prime_check.py (#1125) 2019-08-13 11:50:13 +02:00
trapezoidal_rule.py Create codespell.yml (#1698) 2020-01-18 13:24:33 +01:00
triplet_sum.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
two_pointer.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
two_sum.py move-files-and-2-renames (#4285) 2021-03-22 10:52:26 +01:00
ugly_numbers.py Created ugly_numbers.py in Python/maths (#2366) 2020-08-29 16:57:34 +02:00
volume.py isort --profile black . (#2181) 2020-07-06 09:44:19 +02:00
zellers_congruence.py Optimized recursive_bubble_sort (#2410) 2020-09-10 10:31:26 +02:00