FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/functions/normal_pdf.py at main · thomasWeise/programmingWithPythonCode · GitHub
thomasWeise
programmingWithPythonCode
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programmingWithPythonCode
/
functions
/
normal_pdf.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
16 lines (12 loc) · 633 Bytes
Breadcrumbs
programmingWithPythonCode
/
functions
/
normal_pdf.py
Copy path
File metadata and controls
16 lines (12 loc) · 633 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""The Probability Density Function (PDF) of the Normal Distribution."""
from
math
import
exp
,
pi
,
sqrt
def
pdf
(
x
:
float
,
mu
:
float
=
0.0
,
sigma
:
float
=
1.0
)
->
float
:
"""
Compute the probability density function of the normal distribution.
:param x: the coordinate at which to evaluate the normal PDF
:param mu: the expected value or arithmetic mean, defaults to `0.0`.
:param sigma: the standard deviation, defaults to `1.0`
:return: the value of the normal PDF at `x`.
"""
s2
:
float
=
2
*
(
sigma
**
2
)
# stored for reuse
return
exp
((
-
((
x
-
mu
)
**
2
))
/
s2
)
/
sqrt
(
pi
*
s2
)
# compute pdf
Back
|
FazBrowse Home
|
New Git URL