Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ef17fdbc
Kaydet (Commit)
ef17fdbc
authored
Şub 28, 2019
tarafından
Raymond Hettinger
Kaydeden (comit)
Miss Islington (bot)
Şub 28, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36018: Add special value tests and make minor tweaks to the docs (GH-12096)
https://bugs.python.org/issue36018
üst
ae2ea33d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
statistics.rst
Doc/library/statistics.rst
+3
-3
statistics.py
Lib/statistics.py
+1
-1
test_statistics.py
Lib/test/test_statistics.py
+8
-0
No files found.
Doc/library/statistics.rst
Dosyayı görüntüle @
ef17fdbc
...
@@ -482,9 +482,9 @@ of applications in statistics, including simulations and hypothesis testing.
...
@@ -482,9 +482,9 @@ of applications in statistics, including simulations and hypothesis testing.
.. class:: NormalDist(mu=0.0, sigma=1.0)
.. class:: NormalDist(mu=0.0, sigma=1.0)
Returns a new *NormalDist* object where *mu* represents the `arithmetic
Returns a new *NormalDist* object where *mu* represents the `arithmetic
mean <https://en.wikipedia.org/wiki/Arithmetic_mean>`_
of data
and *sigma*
mean <https://en.wikipedia.org/wiki/Arithmetic_mean>`_ and *sigma*
represents the `standard deviation
represents the `standard deviation
<https://en.wikipedia.org/wiki/Standard_deviation>`_
of the data
.
<https://en.wikipedia.org/wiki/Standard_deviation>`_.
If *sigma* is negative, raises :exc:`StatisticsError`.
If *sigma* is negative, raises :exc:`StatisticsError`.
...
@@ -579,7 +579,7 @@ of applications in statistics, including simulations and hypothesis testing.
...
@@ -579,7 +579,7 @@ of applications in statistics, including simulations and hypothesis testing.
:class:`NormalDist` Examples and Recipes
:class:`NormalDist` Examples and Recipes
----------------------------------------
----------------------------------------
A
:class:`NormalDist` readily solves classic probability problems.
:class:`NormalDist` readily solves classic probability problems.
For example, given `historical data for SAT exams
For example, given `historical data for SAT exams
<https://blog.prepscholar.com/sat-standard-deviation>`_ showing that scores
<https://blog.prepscholar.com/sat-standard-deviation>`_ showing that scores
...
...
Lib/statistics.py
Dosyayı görüntüle @
ef17fdbc
...
@@ -735,7 +735,7 @@ class NormalDist:
...
@@ -735,7 +735,7 @@ class NormalDist:
return
exp
((
x
-
self
.
mu
)
**
2.0
/
(
-
2.0
*
variance
))
/
sqrt
(
tau
*
variance
)
return
exp
((
x
-
self
.
mu
)
**
2.0
/
(
-
2.0
*
variance
))
/
sqrt
(
tau
*
variance
)
def
cdf
(
self
,
x
):
def
cdf
(
self
,
x
):
'Cumulative d
ensity
function: P(X <= x)'
'Cumulative d
istribution
function: P(X <= x)'
if
not
self
.
sigma
:
if
not
self
.
sigma
:
raise
StatisticsError
(
'cdf() not defined when sigma is zero'
)
raise
StatisticsError
(
'cdf() not defined when sigma is zero'
)
return
0.5
*
(
1.0
+
erf
((
x
-
self
.
mu
)
/
(
self
.
sigma
*
sqrt
(
2.0
))))
return
0.5
*
(
1.0
+
erf
((
x
-
self
.
mu
)
/
(
self
.
sigma
*
sqrt
(
2.0
))))
...
...
Lib/test/test_statistics.py
Dosyayı görüntüle @
ef17fdbc
...
@@ -2113,6 +2113,10 @@ class TestNormalDist(unittest.TestCase):
...
@@ -2113,6 +2113,10 @@ class TestNormalDist(unittest.TestCase):
Y
=
NormalDist
(
100
,
0
)
Y
=
NormalDist
(
100
,
0
)
with
self
.
assertRaises
(
statistics
.
StatisticsError
):
with
self
.
assertRaises
(
statistics
.
StatisticsError
):
Y
.
pdf
(
90
)
Y
.
pdf
(
90
)
# Special values
self
.
assertEqual
(
X
.
pdf
(
float
(
'-Inf'
)),
0.0
)
self
.
assertEqual
(
X
.
pdf
(
float
(
'Inf'
)),
0.0
)
self
.
assertTrue
(
math
.
isnan
(
X
.
pdf
(
float
(
'NaN'
))))
def
test_cdf
(
self
):
def
test_cdf
(
self
):
NormalDist
=
statistics
.
NormalDist
NormalDist
=
statistics
.
NormalDist
...
@@ -2127,6 +2131,10 @@ class TestNormalDist(unittest.TestCase):
...
@@ -2127,6 +2131,10 @@ class TestNormalDist(unittest.TestCase):
Y
=
NormalDist
(
100
,
0
)
Y
=
NormalDist
(
100
,
0
)
with
self
.
assertRaises
(
statistics
.
StatisticsError
):
with
self
.
assertRaises
(
statistics
.
StatisticsError
):
Y
.
cdf
(
90
)
Y
.
cdf
(
90
)
# Special values
self
.
assertEqual
(
X
.
cdf
(
float
(
'-Inf'
)),
0.0
)
self
.
assertEqual
(
X
.
cdf
(
float
(
'Inf'
)),
1.0
)
self
.
assertTrue
(
math
.
isnan
(
X
.
cdf
(
float
(
'NaN'
))))
def
test_properties
(
self
):
def
test_properties
(
self
):
X
=
statistics
.
NormalDist
(
100
,
15
)
X
=
statistics
.
NormalDist
(
100
,
15
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment