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
75634db7
Kaydet (Commit)
75634db7
authored
Eyl 15, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Sync-up with head except for 1.72 which is Py2.5 specific.
üst
f207ffbd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
random.py
Lib/random.py
+10
-10
No files found.
Lib/random.py
Dosyayı görüntüle @
75634db7
...
...
@@ -43,7 +43,6 @@ from warnings import warn as _warn
from
types
import
MethodType
as
_MethodType
,
BuiltinMethodType
as
_BuiltinMethodType
from
math
import
log
as
_log
,
exp
as
_exp
,
pi
as
_pi
,
e
as
_e
from
math
import
sqrt
as
_sqrt
,
acos
as
_acos
,
cos
as
_cos
,
sin
as
_sin
from
math
import
floor
as
_floor
from
os
import
urandom
as
_urandom
from
binascii
import
hexlify
as
_hexlify
...
...
@@ -346,7 +345,7 @@ class Random(_random.Random):
# Math Software, 3, (1977), pp257-260.
random
=
self
.
random
while
True
:
while
1
:
u1
=
random
()
u2
=
1.0
-
random
()
z
=
NV_MAGICCONST
*
(
u1
-
0.5
)
/
u2
...
...
@@ -416,7 +415,7 @@ class Random(_random.Random):
b
=
(
a
-
_sqrt
(
2.0
*
a
))
/
(
2.0
*
kappa
)
r
=
(
1.0
+
b
*
b
)
/
(
2.0
*
b
)
while
True
:
while
1
:
u1
=
random
()
z
=
_cos
(
_pi
*
u1
)
...
...
@@ -425,7 +424,7 @@ class Random(_random.Random):
u2
=
random
()
if
not
(
u2
>=
c
*
(
2.0
-
c
)
and
u2
>
c
*
_exp
(
1.0
-
c
)
):
if
u2
<
c
*
(
2.0
-
c
)
or
u2
<=
c
*
_exp
(
1.0
-
c
):
break
u3
=
random
()
...
...
@@ -463,7 +462,7 @@ class Random(_random.Random):
bbb
=
alpha
-
LOG4
ccc
=
alpha
+
ainv
while
True
:
while
1
:
u1
=
random
()
if
not
1e-7
<
u1
<
.
9999999
:
continue
...
...
@@ -486,18 +485,19 @@ class Random(_random.Random):
# Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle
while
True
:
while
1
:
u
=
random
()
b
=
(
_e
+
alpha
)
/
_e
p
=
b
*
u
if
p
<=
1.0
:
x
=
p
ow
(
p
,
1.0
/
alpha
)
x
=
p
**
(
1.0
/
alpha
)
else
:
# p > 1
x
=
-
_log
((
b
-
p
)
/
alpha
)
u1
=
random
()
if
not
(((
p
<=
1.0
)
and
(
u1
>
_exp
(
-
x
)))
or
((
p
>
1
)
and
(
u1
>
pow
(
x
,
alpha
-
1.0
)))):
if
p
>
1.0
:
if
u1
<=
x
**
(
alpha
-
1.0
):
break
elif
u1
<=
_exp
(
-
x
):
break
return
x
*
beta
...
...
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