RandomChoice[{e1,e2,…}]
eiの一つを擬似乱数的に選ぶ.
RandomChoice[list,n]
n 個の擬似乱数的選択のリストを与える.
RandomChoice[list,{n1,n2,…}]
擬似乱数的選択の n1×n2×…配列を与える.
RandomChoice[{w1,w2,…}{e1,e2,…}]
wiで重みを付けた擬似乱数的選択を与える.
RandomChoice[wlistelist,n]
n 個の重みを付けた選択のリストを与える.
RandomChoice[wlistelist,{n1,n2,…}]
重みを付けた選択の n1×n2×…配列を与える.
RandomChoice
RandomChoice[{e1,e2,…}]
eiの一つを擬似乱数的に選ぶ.
RandomChoice[list,n]
n 個の擬似乱数的選択のリストを与える.
RandomChoice[list,{n1,n2,…}]
擬似乱数的選択の n1×n2×…配列を与える.
RandomChoice[{w1,w2,…}{e1,e2,…}]
wiで重みを付けた擬似乱数的選択を与える.
RandomChoice[wlistelist,n]
n 個の重みを付けた選択のリストを与える.
RandomChoice[wlistelist,{n1,n2,…}]
重みを付けた選択の n1×n2×…配列を与える.
詳細
- RandomChoiceは,単純なランダムサンプリングまたは復元サンプリングとしても知られている.
- RandomChoice[{e1,e2,…}]は,すべての eiから等確率で選択する.
- RandomChoice[i;;j;;k,n]は,Spanを使って,i から j まで刻み幅 k でサンプルを抽出することができる.
- RandomChoiceは,Wolfram言語を実行するたびに擬似乱数的選択の異なる列を与える.SeedRandomを使って特定のシードで始めることができる.
- 使用する擬似乱数生成器を指定するために,SeedRandomにMethodオブションを与えることができる.
例題
すべて開く すべて閉じる例 (4)
RandomChoice[{a, b, c}]RandomChoice[{a, b, c}, 20]RandomChoice[{a, b, c}, {4, 3}]RandomChoice[{0.2, 0.2, 0.6} -> {a, b, c}, 20]RandomChoice[{2, 2, 6} -> {a, b, c}, 20]スコープ (2)
RandomChoice[{Exp[x], x ^ 2, 1 / x, 2}, 10]RandomChoice[{a -> 1, a -> 4, b -> 6}, 10]RandomChoice[-10 ;; 10, 10]RandomChoice[-10 ;; 10 ;; 2, 10]アプリケーション (9)
RandomChoice[{"A", "C", "G", "T"}, 50]StringJoin[%]StringJoin[RandomChoice[{4, 1} -> {"A", "B"}, 80]]RandomChoice[Table[1 / n, {n, 10}] -> Range[10], 30]ArrayPlot[RandomChoice[{Red, Green, Blue}, {20, 20}]]ListLinePlot[Accumulate[RandomChoice[{-1, 1}, 50]]]Graphics[Line[Accumulate[RandomChoice[{-1, 1}, {1000, 2}]]]]Graphics[Line[Accumulate[RandomChoice[Table[{Sin[2Pi i / 6], Cos[2Pi i / 6]}, {i, 6}], 1000]]]]Graphics[Table[RandomChoice[{Disk, Circle}][2{i, j}], {i, 5}, {j, 5}]]GraphPlot[RandomChoice[{0.01, 0.99} -> {1, 0}, {100, 100}]]特性と関係 (2)
SeedRandomを使って繰返しのきくランダムな値を得る:
{RandomChoice[{a, b, c}, 5], RandomChoice[{a, b, c}, 5]}{SeedRandom[1234];RandomChoice[{a, b, c}, 5], SeedRandom[1234];RandomChoice[{a, b, c}, 5]}BlockRandomを使って,あるところで使われたRandomChoiceが他に影響を与えないようにする:
{BlockRandom[RandomChoice[Range[100]]], RandomChoice[Range[100]]}おもしろい例題 (5)
RandomChoice[DictionaryLookup["a" ~~ ___], 10]RandomChoice[Names["*"], 10]StringJoin[RandomChoice[CharacterRange["a", "z"], 80]]StringJoin[RandomChoice[{1, 5} -> {" ", #}]& /@ RandomChoice[CharacterRange["a", "z"], 80]]Graphics[Line[Accumulate[RandomChoice[{-1, 0, 1}, {1000, 2}]]]]Graphics3D[Line[Accumulate[RandomChoice[{-1, 1}, {1000, 3}]]]]テキスト
Wolfram Research (2007), RandomChoice, Wolfram言語関数, https://reference.wolfram.com/language/ref/RandomChoice.html (2014年に更新).
CMS
Wolfram Language. 2007. "RandomChoice." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/RandomChoice.html.
APA
Wolfram Language. (2007). RandomChoice. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomChoice.html
BibTeX
@misc{reference.wolfram_2026_randomchoice, author="Wolfram Research", title="{RandomChoice}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/RandomChoice.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_randomchoice, organization={Wolfram Research}, title={RandomChoice}, year={2014}, url={https://reference.wolfram.com/language/ref/RandomChoice.html}, note=[Accessed: 03-November-2026]}