-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
IQR function is added #8851
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
Merged
Merged
IQR function is added #8851
Changes from 46 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
60235f4
tanh function been added
TMGA-WAY dbea59d
tanh function been added
TMGA-WAY 6e3f28d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d42af7b
tanh function is added
TMGA-WAY 84ea4c1
tanh function is added
TMGA-WAY fa675a4
tanh function is added
TMGA-WAY a6b5d05
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2827b15
tanh function added
TMGA-WAY 8092744
tanh function added
TMGA-WAY 9114b52
tanh function added
TMGA-WAY bbf4067
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY a4ca897
tanh function is added
TMGA-WAY e049502
Apply suggestions from code review
cclauss 20639a6
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY 66cc81a
ELU activation function is added
TMGA-WAY d40c74b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5453434
elu activation is added
TMGA-WAY 0d1546e
ELU activation is added
TMGA-WAY 112611a
Update maths/elu_activation.py
TMGA-WAY dad8cf1
Exponential_linear_unit activation is added
TMGA-WAY 34be18c
Exponential_linear_unit activation is added
TMGA-WAY 1ceb47a
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY aae8727
SiLU activation is added
TMGA-WAY 28da38a
SiLU activation is added
TMGA-WAY ba0f68b
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY fcab387
mish added
TMGA-WAY 6e7ed74
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY b1731ec
mish activation is added
TMGA-WAY ae10683
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY 9a5cb30
inter_quartile_range function is added
TMGA-WAY 3296963
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 95caae2
Mish activation function is added
TMGA-WAY 784199a
Mish action is added
TMGA-WAY c91bc2a
mish activation added
TMGA-WAY 44a5ff8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d6095e6
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY 88f05ec
mish activation added
TMGA-WAY 30bd9c2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9776f93
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY 1355f9d
inter quartile range (IQR) function is added
TMGA-WAY 483d59a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] aa5dccb
IQR function is added
TMGA-WAY 2b5d7c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ee3247b
code optimized in IQR function
TMGA-WAY 436a483
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a3fcc64
Merge branch 'TheAlgorithms:master' into master
TMGA-WAY ae37fc4
interquartile_range function is added
TMGA-WAY 14a3fb4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] da1c063
Update maths/interquartile_range.py
TMGA-WAY 05644a0
Changes on interquartile_range
TMGA-WAY 0e72de6
numpy removed from interquartile_range
TMGA-WAY 9c8c26f
Fixes from code review
cclauss 90748c8
Update interquartile_range.py
cclauss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" | ||
This is the implementation of inter_quartile range (IQR). | ||
|
||
function takes the list of numeric values as input | ||
and return the IQR as output. | ||
|
||
Script inspired from its corresponding Wikipedia article | ||
https://en.wikipedia.org/wiki/Interquartile_range | ||
""" | ||
|
||
import numpy as np | ||
|
||
|
||
def find_median(x: np.array) -> float: | ||
""" | ||
This is the implementation of median. | ||
:param x: The list of numeric values | ||
:return: Median of the list | ||
>>> find_median(x=np.array([1,2,2,3,4])) | ||
2 | ||
|
||
>>> find_median(np.array([1,2,2,3,4,4])) | ||
2.5 | ||
|
||
|
||
""" | ||
length = len(x) | ||
if length % 2: | ||
return x[length // 2] | ||
return float((x[length // 2] + x[(length // 2) - 1]) / 2) | ||
|
||
|
||
def inter_quartile_range(x: np.array) -> float: | ||
cclauss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
This is the implementation of inter_quartile | ||
range for a list of numeric. | ||
:param x: The list of data point | ||
:return: Inter_quartile range | ||
|
||
>>> inter_quartile_range(x=np.array([4,1,2,3,2])) | ||
2.0 | ||
|
||
>>> inter_quartile_range(x=np.array([25,32,49,21,37,43,27,45,31])) | ||
18.0 | ||
""" | ||
length = len(x) | ||
if length == 0: | ||
raise ValueError | ||
tianyizheng02 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
x.sort() | ||
q1 = find_median(x[0 : length // 2]) | ||
half_length = (length // 2) + 1 if length % 2 else length // 2 | ||
q3 = find_median(x[half_length:length]) | ||
return q3 - q1 | ||
|
||
|
||
if __name__ == "__main__": | ||
import doctest | ||
|
||
doctest.testmod() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.