RandomPoint[reg]
領域 reg 内に一様に分布する擬似ランダムな点を与える.
RandomPoint[reg,n]
領域 reg 内に一様に分布する n 個の擬似ランダムな点を与える.
RandomPoint[reg,{n1,n2,…}]
擬似ランダムな点の n1× n2×…配列を与える.
RandomPoint[reg,…,{{xmin,xmax},…}]
境界
に制限する.
RandomPoint
RandomPoint[reg]
領域 reg 内に一様に分布する擬似ランダムな点を与える.
RandomPoint[reg,n]
領域 reg 内に一様に分布する n 個の擬似ランダムな点を与える.
RandomPoint[reg,{n1,n2,…}]
擬似ランダムな点の n1× n2×…配列を与える.
RandomPoint[reg,…,{{xmin,xmax},…}]
境界
に制限する.
詳細とオプション
- RandomPointは,ConstantRegionQでもある任意のRegionQ領域についてのランダムな点を生成する.
- RandomPointは,領域 reg 内に一様に点を生成する.
- RandomPointは,Wolfram言語を実行するたびに,異なる擬似乱数列を与える.SeedRandomを使って特定のシードから始めることができる.
- WorkingPrecision->p と設定すると,精度 p の乱数が生成される.
例題
すべて開く すべて閉じる例 (3)
pts = RandomPoint[Disk[], 5000];Graphics[{PointSize[Tiny], Point[pts]}]pl = RandomPoint[Circle[], {3, 100}];Table[Graphics[Point[pts]], {pts, pl}]pts = RandomPoint[Cylinder[], 10 ^ 4];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]スコープ (22)
基本的な用法 (5)
ℛ = Ball[];pt = RandomPoint[ℛ]RegionMember[ℛ, pt]ℛ = Triangle[{{0, 0}, {1, 1}, {2, 0}}];pts = RandomPoint[ℛ, 1000];Graphics[{ℛ, Red, PointSize[Tiny], Point[pts]}]ℛ = Disk[];pl = RandomPoint[ℛ, {3, 20}];Table[Graphics[{ℛ, Red, Point[pts]}], {pts, pl}]ℛ = HalfPlane[{{0, 0}, {1, 1}}, {0, 1}];pts = RandomPoint[ℛ, 10 ^ 4, {{0, 1}, {0, 1}}];Graphics[{LightBlue, ℛ, Red, PointSize[Tiny], Point[pts]}, Frame -> True, PlotRangePadding -> 0.1]ℛ = ConicHullRegion[{{0, 0, 0}}, {{-1, 1, 1}, {1, 1, 1}, {-1, 1, 0}, {1, 1, 0}}];pts = RandomPoint[ℛ, 10 ^ 4, {{-1, 1}, {-1, 1}, {-1, 1}}];Graphics3D[{{Opacity[0.5], ℛ}, {Blue, PointSize[Tiny], Point[pts]}}, Axes -> True, PlotRange -> {{-2, 2}, {0, 2}, {-1, 2}}]特別な領域 (6)
RandomPoint[Point[{{1}, {2}, {3}}]]RandomPoint[Interval[{1, 5}], 5]RandomPoint[Point[{{1, 1}, {2, 2}, {3, 3}}]]RandomPoint[Line[{{0, 0}, {1, 1}}]]RandomPoint[Disk[{1, 2}, {3, 4}]]pts = RandomPoint[Circle[], 300];Graphics[Point[pts]]RandomPoint[Point[{{1, 1, 1}, {2, 2, 2}, {3, 3, 3}}]]RandomPoint[Line[{{1, 2, 3}, {4, 5, 6}}]]RandomPoint[Polygon[{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]]RandomPoint[Cone[{{0, 0, 0}, {1, 1, 1}}, 1 / 2]]ℛ = Tetrahedron[];pts = RandomPoint[ℛ, 300];Graphics3D[{{Opacity[0.2], ℛ}, {Green, Sphere[pts, 0.02]}}, Boxed -> False]RandomPoint[Point[{{1, 1, 1, 1}, {2, 2, 2, 2}, {3, 3, 3, 3}}]]RandomPoint[Simplex[{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}]]RandomPoint[Cuboid[{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}]]RandomPoint[Ball[{0, 0, 0, 0, 0, 0, 0}, 8]]数式定義領域 (3)
RandomPoint[ImplicitRegion[x^2 + y^2 ≤ 1, {x, y}]]RandomPoint[ImplicitRegion[x^2 + y^2 ≤ 1, {x, y, {z, 0, 2}}]]ℛ = ImplicitRegion[x ^ 2 - 2y ^ 2 <= 1, {{x, -3, 3}, {y, -4, 4}}];pts = RandomPoint[ℛ, 10 ^ 4, {{-3, 3}, {-4, 4}}];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = ParametricRegion[{{s, (1 + t) s ^ 2 - t}, -1 ≤ s ≤ 1 && 0 ≤ t ≤ 1}, {s, t}];pts = RandomPoint[ℛ, 5000];Graphics[{PointSize[Tiny], Point[pts]}]メッシュ領域 (4)
2DのMeshRegion:
ℛ = DelaunayMesh[RandomReal[8, {50, 2}]];pts = RandomPoint[ℛ, 2000];Show[ℛ, Graphics[{Red, PointSize[Tiny], Point[pts]}]]ℛ = DelaunayMesh[RandomReal[8, {50, 3}]];pts = RandomPoint[ℛ, 200];Show[HighlightMesh[RegionBoundary[ℛ], Style[2, Opacity[0.1]]], Graphics3D[{Green, Sphere[pts, 0.2]}]]ℛ = ConvexHullMesh[RandomReal[8, {50, 2}]];pts = RandomPoint[ℛ, 2000];Show[ℛ, Graphics[{Red, PointSize[Tiny], Point[pts]}]]ℛ = ConvexHullMesh[RandomReal[8, {50, 3}]];pts = RandomPoint[ℛ, 200];Show[HighlightMesh[RegionBoundary[ℛ], Style[2, Opacity[0.1]]], Graphics3D[{Green, Sphere[pts, 0.2]}]]派生領域 (4)
2領域のRegionIntersection:
ℛ = RegionIntersection[Disk[{0, 0}, 1], Disk[{0, 1}, 1]];pts = RandomPoint[ℛ, 5000];Graphics[{PointSize[Tiny], Point[pts]}]混合次元領域のRegionUnion:
ℛ = RegionUnion[Circle[{1, 0}, 1], Disk[{0, 0}, 1]];DiscretizeRegion[ℛ]pts = RandomPoint[ℛ, 5000];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = TransformedRegion[Disk[{0, 0}, 1], ShearingTransform[Pi / 4, {1, 0}, {0, 1}]];pts = RandomPoint[ℛ, 3000];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = RegionBoundary[Disk[{0, 0}, 1]];
DiscretizeRegion[ℛ]pts = RandomPoint[ℛ, 100];Graphics[Point[pts]]アプリケーション (24)
2Dギャラリー (9)
v = RandomPoint[Sphere[{0, 0}, 1], 200];Graphics[Table[Arrow[{{0, 0}, p}], {p, v}]]ℛ = ParametricRegion[
{(4 Sin[t] ^ 3) / 5, 1 / 20 (13 Cos[t] - 5 Cos[2 t] - 2 Cos[3 t] - Cos[4 t])}, {{t, 0, 2 π}}];pts = RandomPoint[ℛ, 10 ^ 3, {{-1, 1}, {-1, 1}}];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = ParametricRegion[{1 / 5 (E ^ Cos[t] - 2 Cos[4 t] + Sin[t / 12] ^ 5) Sin[t], 1 / 5 Cos[t] (E ^ Cos[t] - 2 Cos[4 t] + Sin[t / 12] ^ 5) - 1 / 6}, {{t, 0, 100}}];pts = RandomPoint[ℛ, 5000, {{-1, 1}, {-1, 1}}];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = ImplicitRegion[x ^ 3 - 3 x y ^ 2 + (x ^ 2 + y ^ 2) ^ 2 == 0, {x, y}];pts = RandomPoint[ℛ, 10 ^ 3, {{-1, 1}, {-1, 1}}];Graphics[{PointSize[Tiny], Point[pts]}]Graphicsシーン:
p = RandomReal[1, {20, 2}];
g = Graphics[{BSplineCurve[p], Line[p]}];pts = RandomPoint[DiscretizeGraphics[g], 10 ^ 4];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = ImplicitRegion[-1 + (-1 + 18 x^2 - 48 x^4 + 32 x^6)^2 + (-1 + 18 y^2 - 48 y^4 + 32 y^6)^2 ≤ 0, {x, y}];pts = RandomPoint[ℛ, 10 ^ 4];Graphics[{PointSize[Tiny], Point[pts]}]ℛ = ParametricRegion[{{s, s t}, s ^ 2 + t ^ 2 ≤ 1}, {s, t}];pts = RandomPoint[ℛ, 10 ^ 4];Graphics[{PointSize[Tiny], Point[pts]}]CountryData["Austria", "Polygon"]ℛ = DiscretizeRegion[CountryData["Austria", "Polygon"]];pts = RandomPoint[ℛ, 5000];Graphics3D[{PointSize[Tiny], Point[pts]}]Textプリミティブ:
t = Text[Style["π", Bold]];mr = DiscretizeGraphics[t, _Text, MaxCellMeasure -> 0.1];pts = RandomPoint[mr, 3000];Graphics[{PointSize[Tiny], Point[pts]}]3Dギャラリー (6)
v = RandomPoint[Sphere[{0, 0, 0}, 1], 200];Graphics3D[Table[Arrow[{{0, 0, 0}, p}], {p, v}], Boxed -> False]ℛ = ParametricRegion[{Cos[t], Sin[t], t / 16}, {{t, 0, 9π}}];pts = RandomPoint[ℛ, 10 ^ 3, {{-1, 1}, {-1, 1}, {0, 2}}];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]ℛ = ImplicitRegion[(-1 + x)^2 + y^2 == 1 && x^2 + y^2 + z^2 == 4, {x, y, z}];pts = RandomPoint[ℛ, 10 ^ 3];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]ℛ = ParametricRegion[{(3 + Cos[v])Cos[u], (3 + Cos[v])Sin[u], Sin[v]}, {{u, 0, 2Pi}, {v, 0, 2Pi}}];pts = RandomPoint[ℛ, 4000, {{-4, 4}, {-4, 4}, {-1, 1}}];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]ℛ = ImplicitRegion[4 z ^ 4 + 9 (x ^ 2 + y ^ 2 - 4 z ^ 2) ≤ 1, {x, y, z}];pts = RandomPoint[ℛ, 4000];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]Graphics3Dシーン:
p = Table[{i, j, RandomReal[{-1, 1}]}, {i, 5}, {j, 5}];
g = Graphics3D[{BSplineSurface[p], Sphere[#, 0.1]& /@ p}];pts = RandomPoint[DiscretizeGraphics[g], 5000];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]モンテカルロ法 (2)
ℛ = Disk[{0, 0}, 1];
Graphics[{LightBlue, EdgeForm[Gray], ℛ}]boundingBox = Cuboid@@Transpose[RegionBounds[ℛ]]pts = RandomPoint[boundingBox, 10 ^ 4];col = RegionMember[ℛ, pts] /. {False -> Gray, True -> Red};
Graphics[{ℛ, PointSize[Tiny], {col, Point /@ pts}}]inside = Count[RegionMember[ℛ, pts], True]ratio = N[(inside/Length[pts])]area = Area[boundingBox]area * ratior1 = Annulus[{9, 0}, {3, 4}];
r2 = RegularPolygon[{0, 10}, 2, 3];p1 = RandomPoint[r1, 10 ^ 5];
p2 = RandomPoint[r2, 10 ^ 5];2つの領域からの点の和はミンコフスキー和の領域の点を与える:
msum = p1 + p2;Graphics[{{Blue, r1}, {Brown, r2}, {Orange, PointSize[Tiny], Point[msum]}}]領域の関係 (3)
ランダムなサンプルから領域の近似境界ボックスを計算する.結果の境界は真の境界ボックスの部分集合である:
ℛ = Polygon[{{0, 0}, {2, -1}, {1, 0}, {2, 1}}];pts = RandomPoint[ℛ, 10 ^ 3];CoordinateBounds[pts]RegionBounds[ℛ]{disk, square} = {Disk[{1, 1 / 2}, 1 / 2], Rectangle[]};g = Graphics[{Opacity[0.5], {Green, square}, {Blue, disk}}]円板内のランダムな点の集合からの任意の点が正方形に含まれないことを確かめる:
mf = RegionMember[square];pts = RandomPoint[disk, 10 ^ 3];AllTrue[pts, mf]Show[g, Graphics[{Red, PointSize[Tiny], Point[Select[pts, Not @* mf]]}]]{disk, square} = {Disk[{1 / 2, 1 / 2}, 1 / 2], Rectangle[]};Graphics[{Opacity[0.5], {Green, square}, {Blue, disk}}]円板内のランダムな点の集合からの任意の点が正方形に含まれず,逆もまた真であることを確かめる:
possibleSubregion[r1_, r2_] := AllTrue[RandomPoint[r1, 10 ^ 3], RegionMember[r2]];possibleSubregion[disk, square]possibleSubregion[square, disk]凸面近似 (2)
サンプルを取ることで領域が凸面ではないことを確かめ,もとの領域に帰属しないサンプルの凸結合があることを示す:
ℛ = Polygon[{{0, 0}, {2, -1}, {1, 0}, {2, 1}}];rp = RandomPoint[ℛ, 10];pairs = Line /@ Subsets[rp, {2}];ペアごとの凸結合上の点が領域内になければ,その領域は凸面ではない:
AllTrue[pairs, AllTrue[RandomPoint[#, 10 ^ 2], RegionMember[ℛ]]&]Graphics[{ℛ, Red, pairs}]ch = ConvexHullMesh[RandomPoint[ℛ, 30]];AllTrue[RandomPoint[ch, 10 ^ 4], RegionMember[ℛ]]Show[{Graphics[{ℛ}], HighlightMesh[ch, Style[2, Opacity[0.5]]]}]ℛ = ImplicitRegion[x ^ 3 - 3x y ^ 2 + (x ^ 2 + y ^ 2) ^ 2 < 0, {x, y}];pts = RandomPoint[ℛ, 3000];cm = ConvexHullMesh[pts];Show[cm, Graphics[{Red, PointSize[Tiny], Point[pts]}]]最近点と最遠点 (2)
領域のサンプルを取ることで,領域内の近似最近点を求め,サンプルに対する最近点を計算する.これで,領域までの距離の上界が得られる:
ℛ = Triangle[{{0, 0}, {1, 1}, {2, 0}}];pt = {2, 1};rp = RandomPoint[ℛ, 10 ^ 3];np = First[Nearest[rp, pt]]Graphics[{LightGray, ℛ, Gray, Point[rp], PointSize[Medium], Blue, Point[pt], Red, Point[np], Dashed, Line[{pt, np}]}]apprDist = EuclideanDistance[pt, np]exactDist = RegionDistance[ℛ, pt]//NexactDist < apprDistapproximateFarthest[reg_, pt_] := First[Nearest[RandomPoint[reg, 10 ^ 4], pt, DistanceFunction -> (-Norm[#1 - #2]&)]]ℛ = Triangle[{{0, 0}, {1, 1}, {2, 0}}];pt = {2, 1};fp = approximateFarthest[ℛ, {2, 1}]Graphics[{Point[pt], LightGray, ℛ, Red, Point[fp], Dashed, Line[{pt, fp}]}]特性と関係 (6)
RandomPointは,一様な密度の点を生成する:
ℛ = Disk[];pts = RandomPoint[ℛ, 10 ^ 5];Histogram3D[pts]pts = RandomReal[1, {1000, 2}];ℛ = Point[pts];rp = RandomPoint[ℛ, 10 ^ 4];座標点のRandomChoiceに対応する:
rc = RandomChoice[pts, 10 ^ 4];Histogram3D /@ {rp, rc}Cuboid領域からランダムな点を選ぶ:
bounds = {{-1, 1}, {-1, 1}, {-1, 1}};ℛ = Cuboid@@Transpose[bounds];rp = RandomPoint[ℛ, 5000];UniformDistributionのRandomVariateに対応する:
rv = RandomVariate[UniformDistribution[bounds], 5000];Table[Graphics3D[{PointSize[Tiny], Point[p]}, Boxed -> False], {p, {rp, rv}}]Disk領域からランダムな点を選ぶ:
{a, r} = {1, 3};ℛ = Disk[{a, 0}, r];rp = RandomPoint[ℛ, 10 ^ 4];WignerSemicircleDistributionのRandomVariateに対応する:
rv = RandomVariate[WignerSemicircleDistribution[a, r], 10 ^ 4];Histogram /@ {rp[[All, 1]], rv}Triangle領域からランダムな座標点を選ぶ:
{min, max, mode} = {-1, 2, 1};ℛ = Triangle[{{min, 0}, {max, 0}, {mode, 1}}];rp = RandomPoint[ℛ, 10 ^ 4];TriangularDistributionのRandomVariateに対応する:
rv = RandomVariate[TriangularDistribution[{min, max}, mode], 10 ^ 4];Histogram /@ {rp[[All, 1]], rv}FindInstanceは,特別な領域と数式定義領域の厳密な例を生成することができる:
FindInstance[{x, y, z}∈Sphere[{1, 1, 1}, 1 / 2], {x, y, z}]ℛ = ImplicitRegion[x^2 + y^2 ≤ 1, {x, y}];fi = {x, y} /. FindInstance[{x, y}∈ℛ, {x, y}, Reals, 10 ^ 3];rp = RandomPoint[ℛ, 10 ^ 3];Histogram3D /@ {fi, rp}テキスト
Wolfram Research (2015), RandomPoint, Wolfram言語関数, https://reference.wolfram.com/language/ref/RandomPoint.html.
CMS
Wolfram Language. 2015. "RandomPoint." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomPoint.html.
APA
Wolfram Language. (2015). RandomPoint. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomPoint.html
BibTeX
@misc{reference.wolfram_2026_randompoint, author="Wolfram Research", title="{RandomPoint}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/RandomPoint.html}", note=[Accessed: 01-December-2026]}
BibLaTeX
@online{reference.wolfram_2026_randompoint, organization={Wolfram Research}, title={RandomPoint}, year={2015}, url={https://reference.wolfram.com/language/ref/RandomPoint.html}, note=[Accessed: 01-December-2026]}