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
2d0c2568
Kaydet (Commit)
2d0c2568
authored
Şub 19, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Inline coefficients in gamma(). Add reflection formula. Add comments.
üst
b70bcf59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
test_random.py
Lib/test/test_random.py
+18
-10
No files found.
Lib/test/test_random.py
Dosyayı görüntüle @
2d0c2568
...
@@ -5,7 +5,7 @@ import random
...
@@ -5,7 +5,7 @@ import random
import
time
import
time
import
pickle
import
pickle
import
warnings
import
warnings
from
math
import
log
,
exp
,
sqrt
,
pi
,
fsum
as
msum
from
math
import
log
,
exp
,
sqrt
,
pi
,
fsum
,
sin
from
test
import
support
from
test
import
support
class
TestBasicOps
(
unittest
.
TestCase
):
class
TestBasicOps
(
unittest
.
TestCase
):
...
@@ -383,15 +383,23 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
...
@@ -383,15 +383,23 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
self
.
assert_
(
stop
<
x
<=
start
)
self
.
assert_
(
stop
<
x
<=
start
)
self
.
assertEqual
((
x
+
stop
)
%
step
,
0
)
self
.
assertEqual
((
x
+
stop
)
%
step
,
0
)
_gammacoeff
=
(
0.9999999999995183
,
676.5203681218835
,
-
1259.139216722289
,
def
gamma
(
z
,
sqrt2pi
=
(
2.0
*
pi
)
**
0.5
):
771.3234287757674
,
-
176.6150291498386
,
12.50734324009056
,
# Reflection to right half of complex plane
-
0.1385710331296526
,
0.9934937113930748e-05
,
0.1659470187408462e-06
)
if
z
<
0.5
:
return
pi
/
sin
(
pi
*
z
)
/
gamma
(
1.0
-
z
)
def
gamma
(
z
,
cof
=
_gammacoeff
,
g
=
7
):
# Lanczos approximation with g=7
z
-=
1.0
az
=
z
+
(
7.0
-
0.5
)
s
=
msum
([
cof
[
0
]]
+
[
cof
[
i
]
/
(
z
+
i
)
for
i
in
range
(
1
,
len
(
cof
))])
return
az
**
(
z
-
0.5
)
/
exp
(
az
)
*
sqrt2pi
*
fsum
([
z
+=
0.5
0.9999999999995183
,
return
(
z
+
g
)
**
z
/
exp
(
z
+
g
)
*
sqrt
(
2.0
*
pi
)
*
s
676.5203681218835
/
z
,
-
1259.139216722289
/
(
z
+
1.0
),
771.3234287757674
/
(
z
+
2.0
),
-
176.6150291498386
/
(
z
+
3.0
),
12.50734324009056
/
(
z
+
4.0
),
-
0.1385710331296526
/
(
z
+
5.0
),
0.9934937113930748e-05
/
(
z
+
6.0
),
0.1659470187408462e-06
/
(
z
+
7.0
),
])
class
TestDistributions
(
unittest
.
TestCase
):
class
TestDistributions
(
unittest
.
TestCase
):
def
test_zeroinputs
(
self
):
def
test_zeroinputs
(
self
):
...
...
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