Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

translate library/random.po#1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mattwang44 merged 3 commits intopython:3.13fromDr-XYZ:p1
Mar 8, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 171 additions & 22 deletionslibrary/random.po
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,25 +3,26 @@
#
# Translators:
# Allen Wu <allen91.wu@gmail.com>, 2021
# Dr.XYZ <dr.xyz.tw@gmail.com>, 2025
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-27 00:14+0000\n"
"PO-Revision-Date:2023-01-23 22:47+0800\n"
"Last-Translator:Allen Wu <allen91.wu@gmail.com>\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.2.2\n"
"X-Generator: Poedit 3.5\n"

#: ../../library/random.rst:2
msgid ":mod:`!random` --- Generate pseudo-random numbers"
msgstr ":mod:`!random` ---生成偽隨機數"
msgstr ":mod:`!random` ---產生偽隨機數"

#: ../../library/random.rst:7
msgid "**Source code:** :source:`Lib/random.py`"
Expand All@@ -41,7 +42,7 @@ msgid ""
"replacement."
msgstr ""
"對於整數,可以從範圍中進行均勻選擇。對於序列,有一個隨機元素的均勻選擇,一個"
"用來原地 (in-place) 產生隨機排列清單的函式,以及一個用來隨機取樣不替換的函"
"用來原地 (in-place) 產生隨機排列清單的函式,以及一個用來隨機取樣不重置的函"
"式。"

#: ../../library/random.rst:19
Expand All@@ -51,7 +52,7 @@ msgid ""
"generating distributions of angles, the von Mises distribution is available."
msgstr ""
"在實數線上,有一些函式用於處理均勻分佈、常態分佈(高斯分佈)、對數常態分佈、"
"負指數分佈、gamma 分佈和 Beta 分佈。對於生成角度分佈,可以使用馮·米塞斯分佈 "
"負指數分佈、gamma 分佈和 Beta 分佈。對於產生角度分佈,可以使用馮·米塞斯分佈 "
"(von Mises distribution)。"

#: ../../library/random.rst:23
Expand All@@ -66,7 +67,7 @@ msgid ""
"purposes, and is completely unsuitable for cryptographic purposes."
msgstr ""
"幾乎所有 module 函式都相依於基本函式 :func:`.random`,此函式在半開放範圍 "
"``0.0 <= X < 1.0``內均勻地生成一個隨機 float(浮點數)。Python 使用 "
"``0.0 <= X < 1.0``內均勻地產生一個隨機 float(浮點數)。Python 使用 "
"Mersenne Twister(梅森旋轉演算法)作為核心的產生器,它產生 53 位元精度 "
"float,其週期為 2\\*\\*19937-1,透過 C 語言進行底層的實作既快速又支援執行緒安"
"全 (threadsafe)。Mersenne Twister 是現存最廣泛被驗證的隨機數產生器之一,但是"
Expand DownExpand Up@@ -137,6 +138,9 @@ msgid ""
"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"
Expand DownExpand Up@@ -177,7 +181,7 @@ msgid ""
"generates a narrower range of seeds."
msgstr ""
"若使用版本 1(為復現於舊版本 Python 中產生隨機序列而提供),:class:`str` 和 :"
"class:`bytes`的演算法會生成範圍更窄的種子 (seed)。"
"class:`bytes`的演算法會產生範圍更窄的種子 (seed)。"

#: ../../library/random.rst:90
msgid ""
Expand DownExpand Up@@ -816,6 +820,31 @@ msgid ""
">>> 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:510
msgid "Simulations::"
Expand DownExpand Up@@ -846,6 +875,27 @@ msgid ""
">>> 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:535
msgid ""
Expand DownExpand Up@@ -916,6 +966,26 @@ msgid ""
"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:575
msgid ""
Expand DownExpand Up@@ -950,6 +1020,31 @@ msgid ""
"print(f'Mean wait: {mean(waits):.1f} Max wait: {max(waits):.1f}')\n"
"print('Quartiles:', [round(q, 1) for q in quantiles(waits)])"
msgstr ""
"from heapq import heapify, heapreplace\n"
"from random import expovariate, gauss\n"
"from statistics import mean, quantiles\n"
"\n"
"average_arrival_interval = 5.6\n"
"average_service_time = 15.0\n"
"stdev_service_time = 3.5\n"
"num_servers = 3\n"
"\n"
"waits = []\n"
"arrival_time = 0.0\n"
"servers = [0.0] * num_servers # 每個伺服器可用的時間\n"
"heapify(servers)\n"
"for i in range(1_000_000):\n"
" arrival_time += expovariate(1.0 / average_arrival_interval)\n"
" next_server_available = servers[0]\n"
" wait = max(0.0, next_server_available - arrival_time)\n"
" waits.append(wait)\n"
" service_duration = max(0.0, gauss(average_service_time, "
"stdev_service_time))\n"
" service_completed = arrival_time + wait + service_duration\n"
" heapreplace(servers, service_completed)\n"
"\n"
"print(f'平均等待時間:{mean(waits):.1f} 最大等待時間:{max(waits):.1f}')\n"
"print('四分位數:', [round(q, 1) for q in quantiles(waits)])"

#: ../../library/random.rst:604
msgid ""
Expand DownExpand Up@@ -1028,6 +1123,31 @@ msgid ""
" indices = sorted(random.choices(range(n), k=r))\n"
" return tuple(pool[i] for i in indices)"
msgstr ""
"def random_product(*args, repeat=1):\n"
" \"從 itertools.product(*args, **kwds) 中隨機選擇\"\n"
" pools = [tuple(pool) for pool in args] * repeat\n"
" return tuple(map(random.choice, pools))\n"
"\n"
"def random_permutation(iterable, r=None):\n"
" \"從 itertools.permutations(iterable, r) 中隨機選擇\"\n"
" pool = tuple(iterable)\n"
" r = len(pool) if r is None else r\n"
" return tuple(random.sample(pool, r))\n"
"\n"
"def random_combination(iterable, r):\n"
" \"從 itertools.combinations(iterable, r) 中隨機選擇\"\n"
" pool = tuple(iterable)\n"
" n = len(pool)\n"
" indices = sorted(random.sample(range(n), r))\n"
" return tuple(pool[i] for i in indices)\n"
"\n"
"def random_combination_with_replacement(iterable, r):\n"
" \"有重置地選擇 r 個元素。結果按可疊代物件排序。\"\n"
" # 結果將在 set(itertools.combinations_with_replacement(iterable, r)) 中\n"
" pool = tuple(iterable)\n"
" n = len(pool)\n"
" indices = sorted(random.choices(range(n), k=r))\n"
" return tuple(pool[i] for i in indices)"

#: ../../library/random.rst:659
msgid ""
Expand DownExpand Up@@ -1131,64 +1251,64 @@ msgstr ""

#: ../../library/random.rst:713
msgid "Command-line usage"
msgstr ""
msgstr "命令列用法"

#: ../../library/random.rst:717
msgid "The :mod:`!random` module can be executed from the command line."
msgstr ""
msgstr ":mod:`!random` 模組可以從命令列執行。"

#: ../../library/random.rst:719
msgid ""
"python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]"
msgstr ""
"python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]"

#: ../../library/random.rst:723
#, fuzzy
msgid "The following options are accepted:"
msgstr "以下函式產生離散分佈。"
msgstr "接受以下選項:"

#: ../../library/random.rst:729
msgid "Show the help message and exit."
msgstr ""
msgstr "顯示幫助訊息並退出。"

#: ../../library/random.rst:734
msgid "Print a random choice, using :meth:`choice`."
msgstr ""
msgstr "列印一個隨機選擇,使用 :meth:`choice`。"

#: ../../library/random.rst:739
msgid ""
"Print a random integer between 1 and N inclusive, using :meth:`randint`."
msgstr ""
msgstr "列印 1 到 N(含)之間的隨機整數,使用 :meth:`randint`。"

#: ../../library/random.rst:744
msgid ""
"Print a random floating-point number between 0 and N inclusive, using :meth:"
"`uniform`."
msgstr ""
msgstr "列印 0 到 N(含)之間的隨機浮點數,使用 :meth:`uniform`。"

#: ../../library/random.rst:747
msgid "If no options are given, the output depends on the input:"
msgstr ""
msgstr "如果未給定選項,則輸出取決於輸入:"

#: ../../library/random.rst:749
msgid "String or multiple: same as :option:`--choice`."
msgstr ""
msgstr "字串或多個:與 :option:`--choice` 相同。"

#: ../../library/random.rst:750
msgid "Integer: same as :option:`--integer`."
msgstr ""
msgstr "整數:與 :option:`--integer` 相同。"

#: ../../library/random.rst:751
msgid "Float: same as :option:`--float`."
msgstr ""
msgstr "浮點數:與 :option:`--float` 相同。"

#: ../../library/random.rst:756
msgid "Command-line example"
msgstr ""
msgstr "命令列範例"

#: ../../library/random.rst:758
msgid "Here are some examples of the :mod:`!random` command-line interface:"
msgstr ""
msgstr "以下是 :mod:`!random` 命令列介面的一些範例:"

#: ../../library/random.rst:760
msgid ""
Expand DownExpand Up@@ -1222,3 +1342,32 @@ msgid ""
"$ python -m random --float 6\n"
"3.1942323316565915"
msgstr ""
"$ # 隨機選擇一個\n"
"$ python -m random egg bacon sausage spam \"Lobster Thermidor aux "
"crevettes with a Mornay sauce\"\n"
"Lobster Thermidor aux crevettes with a Mornay sauce\n"
"\n"
"$ # 隨機整數\n"
"$ python -m random 6\n"
"6\n"
"\n"
"$ # 隨機浮點數\n"
"$ python -m random 1.8\n"
"1.7080016272295635\n"
"\n"
"$ # 使用明確的引數\n"
"$ python -m random --choice egg bacon sausage spam \"Lobster Thermidor "
"aux crevettes with a Mornay sauce\"\n"
"egg\n"
"\n"
"$ python -m random --integer 6\n"
"3\n"
"\n"
"$ python -m random --float 1.8\n"
"1.5666339105010318\n"
"\n"
"$ python -m random --integer 6\n"
"5\n"
"\n"
"$ python -m random --float 6\n"
"3.1942323316565915"

[8]ページ先頭

©2009-2025 Movatter.jp