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
2589ee3e
Kaydet (Commit)
2589ee3e
authored
Kas 17, 2016
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Minor touch-ups to the random module examples
üst
be1ed8b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
random.rst
Doc/library/random.rst
+6
-5
No files found.
Doc/library/random.rst
Dosyayı görüntüle @
2589ee3e
...
...
@@ -344,15 +344,15 @@ Basic usage::
>>> deck
['king', 'queen', 'ace', 'jack']
>>> random.sample([1, 2, 3, 4, 5],
3)
# Three samples without replacement
>>> random.sample([1, 2, 3, 4, 5],
k=3)
# Three samples without replacement
[4, 1, 5]
>>> # Six weighted samples with replacement
>>> choices(['red', 'black', 'green'], [18, 18, 2], k=6)
['red', 'green', 'black', 'black', 'red', 'black']
# Probability of getting 5 or more heads from 7 spins
of a biased coin
# that settles on heads 60% of the time.
# Probability of getting 5 or more heads from 7 spins
#
of a biased coin
that settles on heads 60% of the time.
>>> n = 10000
>>> cw = [0.60, 1.00]
>>> sum(choices('HT', cum_weights=cw, k=7).count('H') >= 5 for i in range(n)) / n
...
...
@@ -369,5 +369,6 @@ sample of size five::
data = 1, 2, 4, 4, 10
means = sorted(mean(choices(data, k=5)) for i in range(20))
print('The sample mean of {:.1f} has a 90% confidence interval '
'from {:.1f} to {:.1f}'.format(mean(data), means[1], means[-2]))
print(f'The sample mean of {mean(data):.1f} has a 90% confidence '
f'interval from {means[1]:.1f} to {means[-2]:.1f}')
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