-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathrandom.po
More file actions
1381 lines (1243 loc) · 56.1 KB
/
random.po
File metadata and controls
1381 lines (1243 loc) · 56.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
# Allen Wu <allen91.wu@gmail.com>, 2021
# Dr.XYZ <dr.xyz.tw@gmail.com>, 2025
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-12-20 00:15+0000\n"
"PO-Revision-Date: 2025-03-07 19:17+0800\n"
"Last-Translator: Dr.XYZ <dr.xyz.tw@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.5\n"
#: ../../library/random.rst:2
msgid ":mod:`!random` --- Generate pseudo-random numbers"
msgstr ":mod:`!random` --- 產生偽隨機數"
#: ../../library/random.rst:7
msgid "**Source code:** :source:`Lib/random.py`"
msgstr "**原始碼:**\\ :source:`Lib/random.py`"
#: ../../library/random.rst:11
msgid ""
"This module implements pseudo-random number generators for various "
"distributions."
msgstr "本章中所提及的 module(模組)用來實現各種分佈的虛擬隨機數產生器。"
#: ../../library/random.rst:14
msgid ""
"For integers, there is uniform selection from a range. For sequences, there "
"is uniform selection of a random element, a function to generate a random "
"permutation of a list in-place, and a function for random sampling without "
"replacement."
msgstr ""
"對於整數,可以從範圍中進行均勻選擇。對於序列,有一個隨機元素的均勻選擇,一個"
"用來原地 (in-place) 產生隨機排列清單的函式,以及一個用來隨機取樣不重置的函"
"式。"
#: ../../library/random.rst:19
msgid ""
"On the real line, there are functions to compute uniform, normal (Gaussian), "
"lognormal, negative exponential, gamma, and beta distributions. For "
"generating distributions of angles, the von Mises distribution is available."
msgstr ""
"在實數線上,有一些函式用於處理均勻分佈、常態分佈(高斯分佈)、對數常態分佈、"
"負指數分佈、gamma 分佈和 Beta 分佈。對於產生角度分佈,可以使用馮·米塞斯分佈 "
"(von Mises distribution)。"
#: ../../library/random.rst:23
msgid ""
"Almost all module functions depend on the basic function :func:`.random`, "
"which generates a random float uniformly in the half-open range ``0.0 <= X < "
"1.0``. Python uses the Mersenne Twister as the core generator. It produces "
"53-bit precision floats and has a period of 2\\*\\*19937-1. The underlying "
"implementation in C is both fast and threadsafe. The Mersenne Twister is "
"one of the most extensively tested random number generators in existence. "
"However, being completely deterministic, it is not suitable for all "
"purposes, and is completely unsuitable for cryptographic purposes."
msgstr ""
"幾乎所有 module 函式都相依於基本函式 :func:`.random`,此函式在半開放範圍 "
"``0.0 <= X < 1.0`` 內均勻地產生一個隨機 float(浮點數)。Python 使用 "
"Mersenne Twister(梅森旋轉演算法)作為核心的產生器,它產生 53 位元精度 "
"float,其週期為 2\\*\\*19937-1,透過 C 語言進行底層的實作既快速又支援執行緒安"
"全 (threadsafe)。Mersenne Twister 是現存最廣泛被驗證的隨機數產生器之一,但是"
"基於完全確定性,它並不適合所有目的,並且完全不適合加密目的。"
#: ../../library/random.rst:32
msgid ""
"The functions supplied by this module are actually bound methods of a hidden "
"instance of the :class:`random.Random` class. You can instantiate your own "
"instances of :class:`Random` to get generators that don't share state."
msgstr ""
"該 module 提供的函式實際上是 :class:`random.Random` class(類別)中一個隱藏實"
"例的綁定方法 (bound method)。你可以實例化自己的 :class:`Random` 實例,以得到"
"不共享狀態的產生器。"
#: ../../library/random.rst:36
msgid ""
"Class :class:`Random` can also be subclassed if you want to use a different "
"basic generator of your own devising: see the documentation on that class "
"for more details."
msgstr ""
"如果你想使用你自己設計的基本產生器,:class:`Random` 也可以進行子類別化 "
"(subclass)。有關詳細資訊,請參考該類別的文件。"
#: ../../library/random.rst:40
msgid ""
"The :mod:`random` module also provides the :class:`SystemRandom` class which "
"uses the system function :func:`os.urandom` to generate random numbers from "
"sources provided by the operating system."
msgstr ""
":mod:`random` module 也提供了 :class:`SystemRandom` class,使用系統函式 :"
"func:`os.urandom` 從作業系統提供的來源產生隨機數。"
#: ../../library/random.rst:46
msgid ""
"The pseudo-random generators of this module should not be used for security "
"purposes. For security or cryptographic uses, see the :mod:`secrets` module."
msgstr ""
"本章所提及的虛擬隨機數產生器不應該使用於安全目的。有關安全性或加密用途,請參"
"考 :mod:`secrets` module。"
#: ../../library/random.rst:52
msgid ""
"M. Matsumoto and T. Nishimura, \"Mersenne Twister: A 623-dimensionally "
"equidistributed uniform pseudorandom number generator\", ACM Transactions on "
"Modeling and Computer Simulation Vol. 8, No. 1, January pp.3--30 1998."
msgstr ""
"M. Matsumoto and T. Nishimura, \"Mersenne Twister: A 623-dimensionally "
"equidistributed uniform pseudorandom number generator\", ACM Transactions on "
"Modeling and Computer Simulation Vol. 8, No. 1, January pp.3--30 1998."
#: ../../library/random.rst:57
msgid ""
"`Complementary-Multiply-with-Carry recipe <https://code.activestate.com/"
"recipes/576707-long-period-random-number-generator/>`_ for a compatible "
"alternative random number generator with a long period and comparatively "
"simple update operations."
msgstr ""
"`進位互補乘法 (Complementary-Multiply-with-Carry) 用法 <https://code."
"activestate.com/recipes/576707-long-period-random-number-generator/>`_,可作"
"為隨機數產生器的一個可相容替代方案,具有較長的週期和相對簡單的更新操作。"
#: ../../library/random.rst:63
msgid ""
"The global random number generator and instances of :class:`Random` are "
"thread-safe. However, in the free-threaded build, concurrent calls to the "
"global generator or to the same instance of :class:`Random` may encounter "
"contention and poor performance. Consider using separate instances of :class:"
"`Random` per thread instead."
msgstr ""
"全域隨機數產生器和 :class:`Random` 的實例是執行緒安全的。然而,在自由執行緒構"
"建中,對全域產生器或同一 :class:`Random` 實例的並行呼叫可能會遇到爭用和性能不"
"佳。請考慮改為每個執行緒使用單獨的 :class:`Random` 實例。"
#: ../../library/random.rst:70
msgid "Bookkeeping functions"
msgstr "簿記函式 (bookkeeping functions)"
#: ../../library/random.rst:74
msgid "Initialize the random number generator."
msgstr "初始化隨機數產生器。"
#: ../../library/random.rst:76
msgid ""
"If *a* is omitted or ``None``, the current system time is used. If "
"randomness sources are provided by the operating system, they are used "
"instead of the system time (see the :func:`os.urandom` function for details "
"on availability)."
msgstr ""
"如果 *a* 被省略或為 ``None``,則使用目前系統時間。如果隨機來源由作業系統提"
"供,則使用它們而不是系統時間(有關可用性的詳細資訊,請參考 :func:`os."
"urandom` 函式)。"
#: ../../library/random.rst:81
msgid "If *a* is an int, its absolute value is used directly."
msgstr "如果 *a* 為 int(整數),則直接使用其絕對值。"
#: ../../library/random.rst:83
msgid ""
"With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:"
"`bytearray` object gets converted to an :class:`int` and all of its bits are "
"used."
msgstr ""
"如使用版本 2(預設值),:class:`str`、:class:`bytes` 或 :class:`bytearray` 物"
"件將轉換為 :class:`int`,並使用其所有位元。"
#: ../../library/random.rst:86
msgid ""
"With version 1 (provided for reproducing random sequences from older "
"versions of Python), the algorithm for :class:`str` and :class:`bytes` "
"generates a narrower range of seeds."
msgstr ""
"若使用版本 1(為復現於舊版本 Python 中產生隨機序列而提供),:class:`str` 和 :"
"class:`bytes` 的演算法會產生範圍更窄的種子 (seed)。"
#: ../../library/random.rst:90
msgid ""
"Moved to the version 2 scheme which uses all of the bits in a string seed."
msgstr "移至版本 2 方案,該方案使用字串種子中的所有位元。"
#: ../../library/random.rst:93
msgid ""
"The *seed* must be one of the following types: ``None``, :class:`int`, :"
"class:`float`, :class:`str`, :class:`bytes`, or :class:`bytearray`."
msgstr ""
"*seed* 必須是以下型別之一:``None``、:class:`int`、:class:`float`、:class:"
"`str`、:class:`bytes`、:class:`bytearray`。"
#: ../../library/random.rst:100
msgid ""
"Return an object capturing the current internal state of the generator. "
"This object can be passed to :func:`setstate` to restore the state."
msgstr ""
"回傳一個物件,捕獲產生器的目前內部狀態。此物件可以傳遞給 :func:`setstate` 以"
"恢復狀態。"
#: ../../library/random.rst:106
msgid ""
"*state* should have been obtained from a previous call to :func:`getstate`, "
"and :func:`setstate` restores the internal state of the generator to what it "
"was at the time :func:`getstate` was called."
msgstr ""
"*state* 應該要從之前對 :func:`getstate` 的呼叫中獲得,並且以 :func:"
"`setstate` 將產生器的內部狀態恢復到呼叫 :func:`getstate` 時的狀態。"
#: ../../library/random.rst:112
msgid "Functions for bytes"
msgstr "回傳位元組的函式"
#: ../../library/random.rst:116
msgid "Generate *n* random bytes."
msgstr "產生 *n* 個隨機位元組。"
#: ../../library/random.rst:118
msgid ""
"This method should not be used for generating security tokens. Use :func:"
"`secrets.token_bytes` instead."
msgstr ""
"此方法不應使用於產生安全性權杖 (Token)。請改用 :func:`secrets.token_bytes`。"
#: ../../library/random.rst:125
msgid "Functions for integers"
msgstr "回傳整數的函式"
#: ../../library/random.rst:130
msgid "Return a randomly selected element from ``range(start, stop, step)``."
msgstr "傳回從 ``range(start, stop, step)`` 中隨機選擇的元素。"
#: ../../library/random.rst:132
msgid ""
"This is roughly equivalent to ``choice(range(start, stop, step))`` but "
"supports arbitrarily large ranges and is optimized for common cases."
msgstr ""
"這大致相當於 ``choice(range(start, stop, step))``,但支援任意大的範圍,並針對"
"常見情況進行了最佳化。"
#: ../../library/random.rst:135
msgid "The positional argument pattern matches the :func:`range` function."
msgstr "位置引數模式與 :func:`range` 函式相符。"
#: ../../library/random.rst:137
msgid ""
"Keyword arguments should not be used because they can be interpreted in "
"unexpected ways. For example ``randrange(start=100)`` is interpreted as "
"``randrange(0, 100, 1)``."
msgstr ""
"不應使用關鍵字引數,因為它們可能會以意想不到的方式被直譯。例如 "
"``randrange(start=100)`` 會被直譯為 ``randrange(0, 100, 1)``。"
#: ../../library/random.rst:141
msgid ""
":meth:`randrange` is more sophisticated about producing equally distributed "
"values. Formerly it used a style like ``int(random()*n)`` which could "
"produce slightly uneven distributions."
msgstr ""
":meth:`randrange` 在產生均勻分佈的值方面更為複雜。以前,它使用像 "
"``int(random()*n)`` 這樣的樣式,這可能會產生稍微不均勻的分佈。"
#: ../../library/random.rst:146
msgid ""
"Automatic conversion of non-integer types is no longer supported. Calls such "
"as ``randrange(10.0)`` and ``randrange(Fraction(10, 1))`` now raise a :exc:"
"`TypeError`."
msgstr ""
"已經不再支援非整數類型到等效整數的自動轉換。像是 ``randrange(10.0)`` 和 "
"``randrange(Fraction(10, 1))`` 的呼叫將會引發 :exc:`TypeError`。"
#: ../../library/random.rst:153
msgid ""
"Return a random integer *N* such that ``a <= N <= b``. Alias for "
"``randrange(a, b+1)``."
msgstr ""
"回傳一個隨機整數 *N*,使得 ``a <= N <= b``。為 ``randrange(a, b+1)`` 的別名。"
#: ../../library/random.rst:158
msgid ""
"Returns a non-negative Python integer with *k* random bits. This method is "
"supplied with the Mersenne Twister generator and some other generators may "
"also provide it as an optional part of the API. When available, :meth:"
"`getrandbits` enables :meth:`randrange` to handle arbitrarily large ranges."
msgstr ""
"回傳一個具有 *k* 個隨機位元的非負 Python 整數。此方法會隨 Mersenne Twister 產"
"生器一起提供,一些其他的產生器也可能將其作為 API 的可選部分。如果可用,:meth:"
"`getrandbits` 使 :meth:`randrange` 能夠處理任意大的範圍。"
#: ../../library/random.rst:164
msgid "This method now accepts zero for *k*."
msgstr "此方法現在接受 *k* 為零。"
#: ../../library/random.rst:169
msgid "Functions for sequences"
msgstr "回傳序列的函式"
#: ../../library/random.rst:173
msgid ""
"Return a random element from the non-empty sequence *seq*. If *seq* is "
"empty, raises :exc:`IndexError`."
msgstr ""
"從非空序列 *seq* 回傳一個隨機元素。如果 *seq* 為空,則引發 :exc:"
"`IndexError`。"
#: ../../library/random.rst:178
msgid ""
"Return a *k* sized list of elements chosen from the *population* with "
"replacement. If the *population* is empty, raises :exc:`IndexError`."
msgstr ""
"回傳從 *population* 中重置取樣出的一個大小為 *k* 的元素 list。如果 "
"*population* 為空,則引發 :exc:`IndexError`。"
#: ../../library/random.rst:181
msgid ""
"If a *weights* sequence is specified, selections are made according to the "
"relative weights. Alternatively, if a *cum_weights* sequence is given, the "
"selections are made according to the cumulative weights (perhaps computed "
"using :func:`itertools.accumulate`). For example, the relative weights "
"``[10, 5, 30, 5]`` are equivalent to the cumulative weights ``[10, 15, 45, "
"50]``. Internally, the relative weights are converted to cumulative weights "
"before making selections, so supplying the cumulative weights saves work."
msgstr ""
"如果指定了 *weights* 序列,則根據相對權重進行選擇。另外,如果給定 "
"*cum_weights* 序列,則根據累積權重進行選擇(可能使用 :func:`itertools."
"accumulate` 計算)。例如,相對權重 ``[10, 5, 30, 5]`` 等同於累積權重 ``[10, "
"15, 45, 50]``。在內部,相對權重在進行選擇之前會轉換為累積權重,因此提供累積權"
"重可以節省工作。"
#: ../../library/random.rst:190
msgid ""
"If neither *weights* nor *cum_weights* are specified, selections are made "
"with equal probability. If a weights sequence is supplied, it must be the "
"same length as the *population* sequence. It is a :exc:`TypeError` to "
"specify both *weights* and *cum_weights*."
msgstr ""
"如果既未指定 *weights* 也未指定 *cum_weights*,則以相等的機率進行選擇。如果提"
"供了加權序列,則該序列的長度必須與 *population* 序列的長度相同。它是一個 :"
"exc:`TypeError` 來指定 *weights* 和 *cum_weights*。"
#: ../../library/random.rst:195
msgid ""
"The *weights* or *cum_weights* can use any numeric type that interoperates "
"with the :class:`float` values returned by :func:`random` (that includes "
"integers, floats, and fractions but excludes decimals). Weights are assumed "
"to be non-negative and finite. A :exc:`ValueError` is raised if all weights "
"are zero."
msgstr ""
"*weights* 或 *cum_weights* 可以使用任何與 :func:`random` 所回傳的 :class:"
"`float` 值(包括整數、float 和分數,但不包括小數)交互操作 (interoperates) 的"
"數值類型。權重假定為非負數和有限的。如果所有權重均為零,則引發 :exc:"
"`ValueError`。"
#: ../../library/random.rst:201
msgid ""
"For a given seed, the :func:`choices` function with equal weighting "
"typically produces a different sequence than repeated calls to :func:"
"`choice`. The algorithm used by :func:`choices` uses floating-point "
"arithmetic for internal consistency and speed. The algorithm used by :func:"
"`choice` defaults to integer arithmetic with repeated selections to avoid "
"small biases from round-off error."
msgstr ""
"對於給定的種子,具有相等權重的 :func:`choices` 函式通常產生與重複呼叫 :func:"
"`choice` 不同的序列。:func:`choices` 使用的演算法使用浮點運算來實現內部一致性"
"和速度。:func:`choice` 使用的演算法預設為整數運算和重複選擇,以避免捨入誤差產"
"生的小偏差。"
#: ../../library/random.rst:210
msgid "Raises a :exc:`ValueError` if all weights are zero."
msgstr "如果所有權重均為零,則引發 :exc:`ValueError`。"
#: ../../library/random.rst:216
msgid "Shuffle the sequence *x* in place."
msgstr "將序列 *x* 原地 (in place) 隨機打亂位置。"
#: ../../library/random.rst:218
msgid ""
"To shuffle an immutable sequence and return a new shuffled list, use "
"``sample(x, k=len(x))`` instead."
msgstr ""
"要打亂一個不可變的序列並回傳一個新的被打亂的 list(串列),請使用 "
"``sample(x, k=len(x))``。"
#: ../../library/random.rst:221
msgid ""
"Note that even for small ``len(x)``, the total number of permutations of *x* "
"can quickly grow larger than the period of most random number generators. "
"This implies that most permutations of a long sequence can never be "
"generated. For example, a sequence of length 2080 is the largest that can "
"fit within the period of the Mersenne Twister random number generator."
msgstr ""
"請注意,即使對於較小的 ``len(x)``,*x* 的置換總數也會快速成長到大於大多數隨機"
"數產生器的週期。這意味著長序列的大多數置換永遠無法產生。例如,長度為 2080 的"
"序列是 Mersenne Twister 隨機數產生器週期內可以容納的最大序列。"
#: ../../library/random.rst:227
msgid "Removed the optional parameter *random*."
msgstr "移除可選參數 *random*。"
#: ../../library/random.rst:233
msgid ""
"Return a *k* length list of unique elements chosen from the population "
"sequence. Used for random sampling without replacement."
msgstr ""
"回傳從母體序列中選擇出的一個包含獨特元素、長度為 *k* 的 list。用於不重置的隨"
"機取樣。"
#: ../../library/random.rst:236
msgid ""
"Returns a new list containing elements from the population while leaving the "
"original population unchanged. The resulting list is in selection order so "
"that all sub-slices will also be valid random samples. This allows raffle "
"winners (the sample) to be partitioned into grand prize and second place "
"winners (the subslices)."
msgstr ""
"回傳包含母體元素的新清單,同時保持原始母體不變。產生的清單按選擇順序排列,因"
"此所有子切片也會是有效的隨機樣本。這允許抽獎獲獎者(樣本)分為大獎和第二名獲"
"獎者(子切片)。"
#: ../../library/random.rst:242
msgid ""
"Members of the population need not be :term:`hashable` or unique. If the "
"population contains repeats, then each occurrence is a possible selection in "
"the sample."
msgstr ""
"母體成員不必是 :term:`hashable` 或唯一的。如果母體包含重複項,則每次出現都是"
"樣本中可能出現的一個選擇。"
#: ../../library/random.rst:245
msgid ""
"Repeated elements can be specified one at a time or with the optional "
"keyword-only *counts* parameter. For example, ``sample(['red', 'blue'], "
"counts=[4, 2], k=5)`` is equivalent to ``sample(['red', 'red', 'red', 'red', "
"'blue', 'blue'], k=5)``."
msgstr ""
"可以一次指定一個重複元素,也可以使用可選的僅關鍵字 *counts* 參數指定重複元"
"素。例如 ``sample(['red', 'blue'], counts=[4, 2], k=5)`` 等同於 "
"``sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5)``。"
#: ../../library/random.rst:250
msgid ""
"To choose a sample from a range of integers, use a :func:`range` object as "
"an argument. This is especially fast and space efficient for sampling from "
"a large population: ``sample(range(10000000), k=60)``."
msgstr ""
"若要從整數範圍中選擇範例,請使用 :func:`range` 物件作為引數。這對於從大型母體"
"中取樣特別快速且節省空間:``sample(range(10000000), k=60)``。"
#: ../../library/random.rst:254
msgid ""
"If the sample size is larger than the population size, a :exc:`ValueError` "
"is raised."
msgstr "如果樣本大小大於母體大小,:exc:`ValueError` 會被引發。"
#: ../../library/random.rst:257
msgid "Added the *counts* parameter."
msgstr "新增 *counts* 參數。"
#: ../../library/random.rst:262
msgid ""
"The *population* must be a sequence. Automatic conversion of sets to lists "
"is no longer supported."
msgstr "*population* 必須是一個序列。不再支援將 set 自動轉換為 list。"
#: ../../library/random.rst:266
msgid "Discrete distributions"
msgstr "離散分布"
#: ../../library/random.rst:268
msgid "The following function generates a discrete distribution."
msgstr "以下函式產生離散分佈。"
#: ../../library/random.rst:272
msgid ""
"`Binomial distribution <https://mathworld.wolfram.com/BinomialDistribution."
"html>`_. Return the number of successes for *n* independent trials with the "
"probability of success in each trial being *p*:"
msgstr ""
"`二項分佈 (Binomial distribution) <https://mathworld.wolfram.com/"
"BinomialDistribution.html>`_。回傳 *n* 個獨立試驗的成功次數,每個試驗的成功機"
"率為 *p*:"
#: ../../library/random.rst:277
msgid "Mathematically equivalent to::"
msgstr "數學上等價於: ::"
#: ../../library/random.rst:279
msgid "sum(random() < p for i in range(n))"
msgstr "sum(random() < p for i in range(n))"
#: ../../library/random.rst:281
msgid ""
"The number of trials *n* should be a non-negative integer. The probability "
"of success *p* should be between ``0.0 <= p <= 1.0``. The result is an "
"integer in the range ``0 <= X <= n``."
msgstr ""
"試驗次數 *n* 應為非負整數。成功的機率 *p* 應在 ``0.0 <= p <= 1.0`` 之間。結果"
"是 ``0 <= X <= n`` 範圍內的整數。"
#: ../../library/random.rst:291
msgid "Real-valued distributions"
msgstr "實數分布"
#: ../../library/random.rst:293
msgid ""
"The following functions generate specific real-valued distributions. "
"Function parameters are named after the corresponding variables in the "
"distribution's equation, as used in common mathematical practice; most of "
"these equations can be found in any statistics text."
msgstr ""
"以下函式產生特定的實數分佈。函式參數以分佈方程中的對應變數命名,如常見的數學"
"實踐所示;這些方程式中的大多數都可以在任意統計文本中找到。"
#: ../../library/random.rst:301
msgid ""
"Return the next random floating-point number in the range ``0.0 <= X < 1.0``"
msgstr "回傳範圍 ``0.0 <= X < 1.0`` 中的下一個隨機浮點數"
#: ../../library/random.rst:306
msgid ""
"Return a random floating-point number *N* such that ``a <= N <= b`` for ``a "
"<= b`` and ``b <= N <= a`` for ``b < a``."
msgstr ""
"回傳一個隨機浮點數 *N*,當 ``a <= b`` 時確保 N 為 ``a <= N <= b`` 、``b < "
"a`` 時確保 N 為 ``b <= N <= a``。"
#: ../../library/random.rst:309
msgid ""
"The end-point value ``b`` may or may not be included in the range depending "
"on floating-point rounding in the expression ``a + (b-a) * random()``."
msgstr ""
"終點值 ``b`` 可能包含在範圍內,也可能不包含在範圍內,取決於運算式 ``a + (b-"
"a) * random()`` 中的浮點捨入。"
#: ../../library/random.rst:316
msgid ""
"Return a random floating-point number *N* such that ``low <= N <= high`` and "
"with the specified *mode* between those bounds. The *low* and *high* bounds "
"default to zero and one. The *mode* argument defaults to the midpoint "
"between the bounds, giving a symmetric distribution."
msgstr ""
"回傳一個隨機浮點數 *N*,使得 ``low <= N <= high``,並在這些邊界之間具有指定"
"的 *mode*。*low* 和 *high* 邊界預設為零和一。*mode* 引數預設為邊界之間的中"
"點,從而給出對稱分佈。"
#: ../../library/random.rst:324
msgid ""
"Beta distribution. Conditions on the parameters are ``alpha > 0`` and "
"``beta > 0``. Returned values range between 0 and 1."
msgstr ""
"Beta(貝它)分布。參數的條件為 ``alpha > 0`` 和 ``beta > 0``。回傳值的範圍介"
"於 0 和 1 之間。"
#: ../../library/random.rst:330
msgid ""
"Exponential distribution. *lambd* is 1.0 divided by the desired mean. It "
"should be nonzero. (The parameter would be called \"lambda\", but that is a "
"reserved word in Python.) Returned values range from 0 to positive infinity "
"if *lambd* is positive, and from negative infinity to 0 if *lambd* is "
"negative."
msgstr ""
"指數分佈。*lambd* 為 1.0 除以所需的平均數。它應該不為零。(該參數將被稱為 "
"\"lambda\",但這是 Python 中的保留字)如果 *lambd* 為正,則回傳值的範圍從 0 "
"到正無窮大;如果 *lambd* 為負,則回傳值的範圍從負無窮大到 0。"
#: ../../library/random.rst:336
msgid "Added the default value for ``lambd``."
msgstr "新增 ``lambd`` 的預設值。"
#: ../../library/random.rst:342
msgid ""
"Gamma distribution. (*Not* the gamma function!) The shape and scale "
"parameters, *alpha* and *beta*, must have positive values. (Calling "
"conventions vary and some sources define 'beta' as the inverse of the scale)."
msgstr ""
"Gamma(伽瑪)分佈。(*不是* Gamma 函式!)。形狀 (shape) 和比例 (scale) 參數 "
"*alpha* 和 *beta* 必須具有正值。(根據呼叫習慣不同,部分來源會將 'beta' 定義"
"為比例的倒數)。"
#: ../../library/random.rst:347
msgid "The probability distribution function is::"
msgstr "Probability distribution function(機率密度函式)是: ::"
#: ../../library/random.rst:349
msgid ""
" x ** (alpha - 1) * math.exp(-x / beta)\n"
"pdf(x) = --------------------------------------\n"
" math.gamma(alpha) * beta ** alpha"
msgstr ""
" x ** (alpha - 1) * math.exp(-x / beta)\n"
"pdf(x) = --------------------------------------\n"
" math.gamma(alpha) * beta ** alpha"
#: ../../library/random.rst:356
msgid ""
"Normal distribution, also called the Gaussian distribution. *mu* is the "
"mean, and *sigma* is the standard deviation. This is slightly faster than "
"the :func:`normalvariate` function defined below."
msgstr ""
"常態分佈,也稱為高斯分佈。*mu* 是平均數,*sigma* 是標準差。這比下面定義的 :"
"func:`normalvariate` 函式快一點。"
#: ../../library/random.rst:361
msgid ""
"Multithreading note: When two threads call this function simultaneously, it "
"is possible that they will receive the same return value. This can be "
"avoided in three ways. 1) Have each thread use a different instance of the "
"random number generator. 2) Put locks around all calls. 3) Use the slower, "
"but thread-safe :func:`normalvariate` function instead."
msgstr ""
"多執行緒須注意:當兩個執行緒同時呼叫此函式時,它們可能會收到相同的傳回值。這"
"可以透過三種方式避免。1)讓每個執行緒使用隨機數產生器的不同實例。2)在所有呼"
"叫周圍加鎖。3)使用較慢但執行緒安全的 :func:`normalvariate` 函式代替。"
#: ../../library/random.rst:368 ../../library/random.rst:384
msgid "*mu* and *sigma* now have default arguments."
msgstr "*mu* 和 *sigma* 現在有預設引數。"
#: ../../library/random.rst:374
msgid ""
"Log normal distribution. If you take the natural logarithm of this "
"distribution, you'll get a normal distribution with mean *mu* and standard "
"deviation *sigma*. *mu* can have any value, and *sigma* must be greater "
"than zero."
msgstr ""
"對數常態分佈。如果你取此分佈的自然對數,你將獲得一個具有平均數 *mu* 和標準差 "
"*sigma* 的常態分佈。*mu* 可以為任何值,並且 *sigma* 必須大於零。"
#: ../../library/random.rst:382
msgid ""
"Normal distribution. *mu* is the mean, and *sigma* is the standard "
"deviation."
msgstr "常態分佈。*mu* 是平均數,*sigma* 是標準差。"
#: ../../library/random.rst:390
msgid ""
"*mu* is the mean angle, expressed in radians between 0 and 2\\*\\ *pi*, and "
"*kappa* is the concentration parameter, which must be greater than or equal "
"to zero. If *kappa* is equal to zero, this distribution reduces to a "
"uniform random angle over the range 0 to 2\\*\\ *pi*."
msgstr ""
"*mu* 是平均角度,以 0 到 2\\*\\ *pi* 之間的弧度表示,*kappa* 是濃度參數,必須"
"大於或等於零。如果 *kappa* 等於零,則此分佈在 0 到 2\\*\\ *pi* 的範圍內將減小"
"為均勻的隨機角度。"
#: ../../library/random.rst:398
msgid "Pareto distribution. *alpha* is the shape parameter."
msgstr "Pareto distribution(柏拉圖分佈)。*alpha* 是形狀參數。"
#: ../../library/random.rst:403
msgid ""
"Weibull distribution. *alpha* is the scale parameter and *beta* is the "
"shape parameter."
msgstr ""
"Weibull distribution(韋伯分佈)。*alpha* 是比例參數,*beta* 是形狀參數。"
#: ../../library/random.rst:408
msgid "Alternative Generator"
msgstr "替代產生器"
#: ../../library/random.rst:412
msgid ""
"Class that implements the default pseudo-random number generator used by "
"the :mod:`random` module."
msgstr "實現 :mod:`random` 模組使用的預設偽隨機數產生器的 class。"
#: ../../library/random.rst:415
msgid ""
"Formerly the *seed* could be any hashable object. Now it is limited to: "
"``None``, :class:`int`, :class:`float`, :class:`str`, :class:`bytes`, or :"
"class:`bytearray`."
msgstr ""
"過去 *seed* 可以是任何可雜湊物件,但現在必須是以下類型之一:``None``、:class:"
"`int`、:class:`float`、:class:`str`、:class:`bytes`、:class:`bytearray`。"
#: ../../library/random.rst:420
msgid ""
"Subclasses of :class:`!Random` should override the following methods if they "
"wish to make use of a different basic generator:"
msgstr ""
"如果 :class:`!Random` 的子類別希望使用不同的基礎產生器,則應該覆寫以下方法:"
#: ../../library/random.rst:425
msgid ""
"Override this method in subclasses to customise the :meth:`~random.seed` "
"behaviour of :class:`!Random` instances."
msgstr ""
"在子類別中覆寫此方法以自訂 :class:`!Random` 實例的 :meth:`~random.seed` 行"
"為。"
#: ../../library/random.rst:430
msgid ""
"Override this method in subclasses to customise the :meth:`~random.getstate` "
"behaviour of :class:`!Random` instances."
msgstr ""
"在子類別中覆寫此方法以自訂 :class:`!Random` 實例的 :meth:`~random.getstate` "
"行為。"
#: ../../library/random.rst:435
msgid ""
"Override this method in subclasses to customise the :meth:`~random.setstate` "
"behaviour of :class:`!Random` instances."
msgstr ""
"在子類別中覆寫此方法以自訂 :class:`!Random` 實例的 :meth:`~random.setstate` "
"行為。"
#: ../../library/random.rst:440
msgid ""
"Override this method in subclasses to customise the :meth:`~random.random` "
"behaviour of :class:`!Random` instances."
msgstr ""
"在子類別中覆寫此方法以自訂 :class:`!Random` 實例的 :meth:`~random.random` 行"
"為。"
#: ../../library/random.rst:443
msgid ""
"Optionally, a custom generator subclass can also supply the following method:"
msgstr "或者,自訂產生器子類別還可以提供以下方法:"
#: ../../library/random.rst:447
msgid ""
"Override this method in subclasses to customise the :meth:`~random."
"getrandbits` behaviour of :class:`!Random` instances."
msgstr ""
"在子類別中覆寫此方法以自訂 :class:`!Random` 實例的 :meth:`~random."
"getrandbits` 行為。"
#: ../../library/random.rst:452
msgid ""
"Override this method in subclasses to customise the :meth:`~random."
"randbytes` behaviour of :class:`!Random` instances."
msgstr ""
"在子類別中覆寫此方法以自訂 :class:`!Random` 實例的 :meth:`~random.randbytes` "
"行為。"
#: ../../library/random.rst:458
msgid ""
"Class that uses the :func:`os.urandom` function for generating random "
"numbers from sources provided by the operating system. Not available on all "
"systems. Does not rely on software state, and sequences are not "
"reproducible. Accordingly, the :meth:`seed` method has no effect and is "
"ignored. The :meth:`getstate` and :meth:`setstate` methods raise :exc:"
"`NotImplementedError` if called."
msgstr ""
"使用 :func:`os.urandom` 函式從作業系統提供的來源產生隨機數的 Class。並非在所"
"有系統上都可用。不依賴於軟體狀態,並且序列不可復現。因此 :meth:`seed` 方法沒"
"有效果且被忽略。如果呼叫 :meth:`getstate` 和 :meth:`setstate` 方法會引發 :"
"exc:`NotImplementedError`。"
#: ../../library/random.rst:467
msgid "Notes on Reproducibility"
msgstr "關於 Reproducibility(復現性)的注意事項"
#: ../../library/random.rst:469
msgid ""
"Sometimes it is useful to be able to reproduce the sequences given by a "
"pseudo-random number generator. By reusing a seed value, the same sequence "
"should be reproducible from run to run as long as multiple threads are not "
"running."
msgstr ""
"有時,能夠重現偽隨機數產生器給出的序列很有用。只要多執行緒未運行,透過重複使"
"用種子值,同一序列就應該可以被復現。"
#: ../../library/random.rst:473
msgid ""
"Most of the random module's algorithms and seeding functions are subject to "
"change across Python versions, but two aspects are guaranteed not to change:"
msgstr ""
"大多數隨機 module 的演算法和 seed 設定函式在 Python 版本中可能會發生變化,但"
"可以保證兩個方面不會改變:"
#: ../../library/random.rst:476
msgid ""
"If a new seeding method is added, then a backward compatible seeder will be "
"offered."
msgstr "如果增加了新的 seed 設定函式,則將提供向後相容的播種器 (seeder)。"
#: ../../library/random.rst:479
msgid ""
"The generator's :meth:`~Random.random` method will continue to produce the "
"same sequence when the compatible seeder is given the same seed."
msgstr ""
"當相容的播種器被賦予相同的種子時,產生器的 :meth:`~Random.random` 方法將持續"
"產生相同的序列。"
#: ../../library/random.rst:485
msgid "Examples"
msgstr "範例"
#: ../../library/random.rst:487
msgid "Basic examples::"
msgstr "基礎範例: ::"
#: ../../library/random.rst:489
msgid ""
">>> random() # Random float: 0.0 <= x < 1.0\n"
"0.37444887175646646\n"
"\n"
">>> uniform(2.5, 10.0) # Random float: 2.5 <= x <= 10.0\n"
"3.1800146073117523\n"
"\n"
">>> expovariate(1 / 5) # Interval between arrivals averaging "
"5 seconds\n"
"5.148957571865031\n"
"\n"
">>> randrange(10) # Integer from 0 to 9 inclusive\n"
"7\n"
"\n"
">>> randrange(0, 101, 2) # Even integer from 0 to 100 "
"inclusive\n"
"26\n"
"\n"
">>> choice(['win', 'lose', 'draw']) # Single random element from a "
"sequence\n"
"'draw'\n"
"\n"
">>> deck = 'ace two three four'.split()\n"
">>> shuffle(deck) # Shuffle a list\n"
">>> deck\n"
"['four', 'two', 'ace', 'three']\n"
"\n"
">>> sample([10, 20, 30, 40, 50], k=4) # Four samples without replacement\n"
"[40, 10, 50, 30]"
msgstr ""
">>> random() # 隨機浮點數:0.0 <= x < 1.0\n"
"0.37444887175646646\n"
"\n"
">>> uniform(2.5, 10.0) # 隨機浮點數:2.5 <= x <= 10.0\n"
"3.1800146073117523\n"
"\n"
">>> expovariate(1 / 5) # 到達間隔平均為 5 秒\n"
"5.148957571865031\n"
"\n"
">>> randrange(10) # 0 到 9(含)的整數\n"
"7\\n\n"
"\n"
">>> randrange(0, 101, 2) # 0 到 100(含)的偶數整數\n"
"26\\n\n"
"\n"
">>> choice(['win', 'lose', 'draw']) # 從序列中隨機選取單一元素\n"
"'draw'\n"
"\n"
">>> deck = 'ace two three four'.split()\n"
">>> shuffle(deck) # 打亂串列\n"
">>> deck\n"
"['four', 'two', 'ace', 'three']\n"
"\n"
">>> sample([10, 20, 30, 40, 50], k=4) # 四個無重置的樣本\n"
"[40, 10, 50, 30]"
#: ../../library/random.rst:515
msgid "Simulations::"
msgstr "模擬: ::"
#: ../../library/random.rst:517
msgid ""
">>> # Six roulette wheel spins (weighted sampling with replacement)\n"
">>> choices(['red', 'black', 'green'], [18, 18, 2], k=6)\n"
"['red', 'green', 'black', 'black', 'red', 'black']\n"
"\n"
">>> # Deal 20 cards without replacement from a deck\n"
">>> # of 52 playing cards, and determine the proportion of cards\n"
">>> # with a ten-value: ten, jack, queen, or king.\n"
">>> deal = sample(['tens', 'low cards'], counts=[16, 36], k=20)\n"
">>> deal.count('tens') / 20\n"
"0.15\n"
"\n"
">>> # Estimate the probability of getting 5 or more heads from 7 spins\n"
">>> # of a biased coin that settles on heads 60% of the time.\n"
">>> sum(binomialvariate(n=7, p=0.6) >= 5 for i in range(10_000)) / 10_000\n"
"0.4169\n"
"\n"
">>> # Probability of the median of 5 samples being in middle two quartiles\n"
">>> def trial():\n"
"... return 2_500 <= sorted(choices(range(10_000), k=5))[2] < 7_500\n"
"...\n"
">>> sum(trial() for i in range(10_000)) / 10_000\n"
"0.7958"
msgstr ""
">>> # 六次輪盤旋轉(有重置的加權抽樣)\n"
">>> choices(['red', 'black', 'green'], [18, 18, 2], k=6)\n"
"['red', 'green', 'black', 'black', 'red', 'black']\n"
"\n"
">>> # 從一副 52 張撲克牌中無重置發 20 張牌\n"
">>> # 並確定具有十點值的牌的比例:十、傑克、王后或國王\n"
">>> deal = sample(['tens', 'low cards'], counts=[16, 36], k=20)\n"
">>> deal.count('tens') / 20\n"
"0.15\n"
"\n"
">>> # 估計從 7 次旋轉中得到 5 次或更多正面的概率\n"
">>> # 使用一枚 60% 概率為正面的偏幣\n"
">>> sum(binomialvariate(n=7, p=0.6) >= 5 for i in range(10_000)) / 10_000\n"
"0.4169\n"
"\n"
">>> # 計算 5 個樣本的中位數位於中間兩個四分位數的概率\n"
">>> def trial():\n"
"... return 2_500 <= sorted(choices(range(10_000), k=5))[2] < 7_500\n"
"...\n"
">>> sum(trial() for i in range(10_000)) / 10_000\n"
"0.7958"
#: ../../library/random.rst:540
msgid ""
"Example of `statistical bootstrapping <https://en.wikipedia.org/wiki/"
"Bootstrapping_(statistics)>`_ using resampling with replacement to estimate "
"a confidence interval for the mean of a sample::"
msgstr ""
"`統計 bootstrapping(自助法) <https://en.wikipedia.org/wiki/"
"Bootstrapping_(statistics)>`_\\ 的範例,使用有重置的重新取樣來估計樣本平均數"
"的信賴區間: ::"
#: ../../library/random.rst:544
msgid ""
"# https://www.thoughtco.com/example-of-bootstrapping-3126155\n"
"from statistics import fmean as mean\n"
"from random import choices\n"
"\n"
"data = [41, 50, 29, 37, 81, 30, 73, 63, 20, 35, 68, 22, 60, 31, 95]\n"
"means = sorted(mean(choices(data, k=len(data))) for i in range(100))\n"
"print(f'The sample mean of {mean(data):.1f} has a 90% confidence '\n"
" f'interval from {means[5]:.1f} to {means[94]:.1f}')"
msgstr ""
"# https://www.thoughtco.com/example-of-bootstrapping-3126155\n"
"from statistics import fmean as mean\n"
"from random import choices\n"
"\n"
"data = [41, 50, 29, 37, 81, 30, 73, 63, 20, 35, 68, 22, 60, 31, 95]\n"
"means = sorted(mean(choices(data, k=len(data))) for i in range(100))\n"
"print(f'The sample mean of {mean(data):.1f} has a 90% confidence '\n"
" f'interval from {means[5]:.1f} to {means[94]:.1f}')"
#: ../../library/random.rst:553
msgid ""
"Example of a `resampling permutation test <https://en.wikipedia.org/wiki/"
"Resampling_(statistics)#Permutation_tests>`_ to determine the statistical "
"significance or `p-value <https://en.wikipedia.org/wiki/P-value>`_ of an "
"observed difference between the effects of a drug versus a placebo::"
msgstr ""
"`重新取樣排列測試 <https://en.wikipedia.org/wiki/"
"Resampling_(statistics)#Permutation_tests>`_\\ 的範例,來確定觀察到的藥物與安"
"慰劑之間差異的統計學意義或 `p 值 <https://en.wikipedia.org/wiki/P-value>`_\\ "
": ::"
#: ../../library/random.rst:559
msgid ""
"# Example from \"Statistics is Easy\" by Dennis Shasha and Manda Wilson\n"
"from statistics import fmean as mean\n"
"from random import shuffle\n"
"\n"
"drug = [54, 73, 53, 70, 73, 68, 52, 65, 65]\n"
"placebo = [54, 51, 58, 44, 55, 52, 42, 47, 58, 46]\n"
"observed_diff = mean(drug) - mean(placebo)\n"
"\n"
"n = 10_000\n"
"count = 0\n"
"combined = drug + placebo\n"
"for i in range(n):\n"
" shuffle(combined)\n"
" new_diff = mean(combined[:len(drug)]) - mean(combined[len(drug):])\n"
" count += (new_diff >= observed_diff)\n"
"\n"
"print(f'{n} label reshufflings produced only {count} instances with a "
"difference')\n"
"print(f'at least as extreme as the observed difference of "
"{observed_diff:.1f}.')\n"
"print(f'The one-sided p-value of {count / n:.4f} leads us to reject the "
"null')\n"
"print(f'hypothesis that there is no difference between the drug and the "
"placebo.')"
msgstr ""
"# 範例來自 Dennis Shasha 和 Manda Wilson 的 \"Statistics is Easy\"\n"
"from statistics import fmean as mean\n"
"from random import shuffle\n"
"\n"
"drug = [54, 73, 53, 70, 73, 68, 52, 65, 65]\n"
"placebo = [54, 51, 58, 44, 55, 52, 42, 47, 58, 46]\n"
"observed_diff = mean(drug) - mean(placebo)\n"
"\n"
"n = 10_000\n"
"count = 0\n"
"combined = drug + placebo\n"
"for i in range(n):\n"
" shuffle(combined)\n"
" new_diff = mean(combined[:len(drug)]) - mean(combined[len(drug):])\n"
" count += (new_diff >= observed_diff)\n"
"\n"
"print(f'{n} 次標籤重新洗牌僅產生 {count} 個差異實例')\n"
"print(f'至少與觀察到的差異 {observed_diff:.1f} 一樣極端。')\n"
"print(f'單邊 p 值 {count / n:.4f} 使我們拒絕無效假設')\n"
"print(f'即藥物與安慰劑之間沒有差異。')"
#: ../../library/random.rst:580
msgid ""
"Simulation of arrival times and service deliveries for a multiserver queue::"