Skip to content

Correcting the Gaussian Formula #2249

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 7 commits into from
Jul 29, 2020
Merged

Conversation

aryan26roy
Copy link
Contributor

@aryan26roy aryan26roy commented Jul 28, 2020

I have added the parenthesis around the 2*sigma^2 term.

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

I have added the parenthesis around the 2*sigma^2 term.
@cclauss
Copy link
Member

cclauss commented Jul 28, 2020

None of the doctests needed to change?!? That implies that the results of the calculation did not change. This needs some doctests which fail under the old formulation and pass under the new formulation.

@aryan26roy
Copy link
Contributor Author

I tried the doctests provided in the code and the new formulation provides exactly the same results.

@cclauss
Copy link
Member

cclauss commented Jul 28, 2020

So this PR corrects an algorithm that was already correct?

https://docs.python.org/3/reference/expressions.html#operator-precedence

@aryan26roy
Copy link
Contributor Author

It turns out when you vary the value of mu, the differences emerge. I have added a doctest which the old formulation would fail. Should i add more?

@TravisBuddy
Copy link

Hey @aryan26roy,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 9c34dd10-d115-11ea-b8d2-e37d5f97d09d

@spamegg1
Copy link
Contributor

spamegg1 commented Jul 29, 2020

@aryan26roy Also try varying the sigma #2212 But large sigma values don't show the difference, they should be small.

@TravisBuddy
Copy link

Hey @aryan26roy,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 23655cd0-d191-11ea-bb2f-e1a2ee6530fc

@aryan26roy
Copy link
Contributor Author

Hey, i have varied the sigma as well. The old formulation will fail the two new doctests. However, it is encountering a build error.

@cclauss
Copy link
Member

cclauss commented Jul 29, 2020

Whitespace errors that should be easy to fix.
https://travis-ci.com/github/TheAlgorithms/Python/builds/177610419#L252

@TravisBuddy
Copy link

Hey @aryan26roy,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: f9dcc340-d1b2-11ea-bb2f-e1a2ee6530fc

@TravisBuddy
Copy link

Hey @aryan26roy,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 07730b80-d1b4-11ea-bb2f-e1a2ee6530fc

@aryan26roy
Copy link
Contributor Author

Hey, i have removed the error.

@@ -21,7 +21,7 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int:

>>> gaussian(1,4,3)
0.0806569081730478

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is an older version. I have updated and removed all the white spaces.

>>> gaussian(1,5,3)
0.05467002489199788

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See?

@cclauss cclauss merged commit 373f193 into TheAlgorithms:master Jul 29, 2020
@TravisBuddy
Copy link

Hey @aryan26roy,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 5c3cb080-d1d2-11ea-bb2f-e1a2ee6530fc

@aryan26roy aryan26roy deleted the patch-2 branch July 30, 2020 08:33
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Correcting the Gaussian Formula

I have added the parenthesis around the 2*sigma^2 term.

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

Co-authored-by: Christian Clauss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants