RandomPoint[reg]
gives a pseudorandom point uniformly distributed in the region reg.
RandomPoint[reg,n]
gives a list of n pseudorandom points uniformly distributed in the region reg.
RandomPoint[reg,{n1,n2,…}]
gives an n1× n2×… array of pseudorandom points.
RandomPoint[reg,…,{{xmin,xmax},…}]
restricts to the bounds
.
RandomPoint
RandomPoint[reg]
gives a pseudorandom point uniformly distributed in the region reg.
RandomPoint[reg,n]
gives a list of n pseudorandom points uniformly distributed in the region reg.
RandomPoint[reg,{n1,n2,…}]
gives an n1× n2×… array of pseudorandom points.
RandomPoint[reg,…,{{xmin,xmax},…}]
restricts to the bounds
.
Details and Options
- RandomPoint can generate random points for any RegionQ region that is also ConstantRegionQ.
- RandomPoint will generate points uniformly in the region reg.
- RandomPoint gives a different sequence of pseudorandom numbers whenever you run the Wolfram Language. You can start with a particular seed using SeedRandom.
- With the setting WorkingPrecision->p, random numbers of precision p will be generated.
Examples
open all close allBasic Examples (3)
Generate a list of points in a unit disk:
pts = RandomPoint[Disk[], 5000];Graphics[{PointSize[Tiny], Point[pts]}]Generate multiple lists of points on a unit circle:
pl = RandomPoint[Circle[], {3, 100}];Table[Graphics[Point[pts]], {pts, pl}]Generate a list of points in a standard cylinder:
pts = RandomPoint[Cylinder[], 10 ^ 4];Graphics3D[{PointSize[Tiny], Point[pts]}, Boxed -> False]Scope (22)
Basic Uses (5)
Generate a point in a unit ball region:
ℛ = Ball[];pt = RandomPoint[ℛ]RegionMember[ℛ, pt]Generate a list of points for a triangle region:
ℛ = Triangle[{{0, 0}, {1, 1}, {2, 0}}];pts = RandomPoint[ℛ, 1000];Graphics[{ℛ, Red, PointSize[Tiny], Point[pts]}]Generate multiple lists of points for a unit disk region:
ℛ = Disk[];pl = RandomPoint[ℛ, {3, 20}];Table[Graphics[{ℛ, Red, Point[pts]}], {pts, pl}]Generate points on an unbounded region within given bounds:
ℛ = HalfPlane[{{0, 0}, {1, 1}}, {0, 1}];pts = RandomPoint[ℛ, 10 ^ 4, {{0, 1}, {0, 1}}];The random points are restricted to
:
Graphics[{LightBlue, ℛ, Red, PointSize[Tiny], Point[pts]}, Frame -> True, PlotRangePadding -> 0.1]Generate points on an unbounded region within given bounds in
:
ℛ = 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}}]Special Regions (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]]Formula Regions (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]}]Mesh Regions (4)
MeshRegion in 2D:
ℛ = 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]}]]BoundaryMeshRegion in 2D:
ℛ = ConvexHullMesh[RandomReal[8, {50, 2}]];pts = RandomPoint[ℛ, 2000];Show[ℛ, Graphics[{Red, PointSize[Tiny], Point[pts]}]]BoundaryMeshRegion in 3D:
ℛ = ConvexHullMesh[RandomReal[8, {50, 3}]];pts = RandomPoint[ℛ, 200];Show[HighlightMesh[RegionBoundary[ℛ], Style[2, Opacity[0.1]]], Graphics3D[{Green, Sphere[pts, 0.2]}]]Derived Regions (4)
RegionIntersection of two regions:
ℛ = RegionIntersection[Disk[{0, 0}, 1], Disk[{0, 1}, 1]];pts = RandomPoint[ℛ, 5000];Graphics[{PointSize[Tiny], Point[pts]}]RegionUnion of mixed-dimensional regions:
ℛ = RegionUnion[Circle[{1, 0}, 1], Disk[{0, 0}, 1]];DiscretizeRegion[ℛ]Points are generated for the maximum dimensional component:
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]]Applications (24)
2D Galleries (9)
Generate a list of uniform random unit vectors in
:
v = RandomPoint[Sphere[{0, 0}, 1], 200];Graphics[Table[Arrow[{{0, 0}, p}], {p, v}]]Visualize a parametric heart curve:
ℛ = 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 scene:
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]}]Mixed implicit and parametric region:
ℛ = 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 primitive:
t = Text[Style["π", Bold]];mr = DiscretizeGraphics[t, _Text, MaxCellMeasure -> 0.1];pts = RandomPoint[mr, 3000];Graphics[{PointSize[Tiny], Point[pts]}]3D Galleries (6)
Generate a list of uniform random unit vectors in
:
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 scene:
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]Monte Carlo Methods (2)
Perform Monte Carlo integration to estimate the area of a unit disk:
ℛ = Disk[{0, 0}, 1];
Graphics[{LightBlue, EdgeForm[Gray], ℛ}]boundingBox = Cuboid@@Transpose[RegionBounds[ℛ]]Uniformly sample over the bounding box of the region:
pts = RandomPoint[boundingBox, 10 ^ 4];col = RegionMember[ℛ, pts] /. {False -> Gray, True -> Red};
Graphics[{ℛ, PointSize[Tiny], {col, Point /@ pts}}]Count the number of samples inside the region:
inside = Count[RegionMember[ℛ, pts], True]Get the ratio of samples inside the region to the total number of sample points:
ratio = N[(inside/Length[pts])]area = Area[boundingBox]Get the approximate area of the region:
area * ratioVisualize the Minkowski sum (orange) of two regions:
r1 = Annulus[{9, 0}, {3, 4}];
r2 = RegularPolygon[{0, 10}, 2, 3];p1 = RandomPoint[r1, 10 ^ 5];
p2 = RandomPoint[r2, 10 ^ 5];Sum of points from two regions gives points of the Minkowski sum region:
msum = p1 + p2;Graphics[{{Blue, r1}, {Brown, r2}, {Orange, PointSize[Tiny], Point[msum]}}]Region Relations (3)
Compute an approximate bounding box for a region from random samples. The resulting bounding will be a subset of the true bounding box:
ℛ = Polygon[{{0, 0}, {2, -1}, {1, 0}, {2, 1}}];pts = RandomPoint[ℛ, 10 ^ 3];CoordinateBounds[pts]Compare with its region bounds:
RegionBounds[ℛ]Show that a region is not a subset of another:
{disk, square} = {Disk[{1, 1 / 2}, 1 / 2], Rectangle[]};g = Graphics[{Opacity[0.5], {Green, square}, {Blue, disk}}]Check if any point from a set of random points in the disk are not in the square:
mf = RegionMember[square];pts = RandomPoint[disk, 10 ^ 3];AllTrue[pts, mf]Visualize the random points in the disk that are not in the square:
Show[g, Graphics[{Red, PointSize[Tiny], Point[Select[pts, Not @* mf]]}]]Determine that two regions are not equal:
{disk, square} = {Disk[{1 / 2, 1 / 2}, 1 / 2], Rectangle[]};Graphics[{Opacity[0.5], {Green, square}, {Blue, disk}}]Check if any point from a set of random points in the disk is not in the square, or vice versa:
possibleSubregion[r1_, r2_] := AllTrue[RandomPoint[r1, 10 ^ 3], RegionMember[r2]];possibleSubregion[disk, square]possibleSubregion[square, disk]Approximate Convexity (2)
Determine that a region is not convex by sampling, and show that there is a convex combination of the samples that is not a member of the original region:
ℛ = Polygon[{{0, 0}, {2, -1}, {1, 0}, {2, 1}}];Generate pairwise convex combinations of random points within the region:
rp = RandomPoint[ℛ, 10];pairs = Line /@ Subsets[rp, {2}];If a point on a pairwise convex combination is not in the region, then the region is not convex:
AllTrue[pairs, AllTrue[RandomPoint[#, 10 ^ 2], RegionMember[ℛ]]&]Graphics[{ℛ, Red, pairs}]Alternatively generate and test points in a convex hull of points:
ch = ConvexHullMesh[RandomPoint[ℛ, 30]];AllTrue[RandomPoint[ch, 10 ^ 4], RegionMember[ℛ]]Show[{Graphics[{ℛ}], HighlightMesh[ch, Style[2, Opacity[0.5]]]}]Compute the approximate convex hull of a region from random points within the region:
ℛ = 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]}]]Nearest and Farthest Points (2)
Find an approximate nearest point in a region by sampling the region and computing the nearest point to the samples. This gives an upper bound for the distance to the region:
ℛ = Triangle[{{0, 0}, {1, 1}, {2, 0}}];pt = {2, 1};Find the nearest point from a set of random points in the region:
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}]}]Compare the resulting distance to the true minimum distance to the region:
apprDist = EuclideanDistance[pt, np]exactDist = RegionDistance[ℛ, pt]//NexactDist < apprDistDefine a function that finds an approximate farthest point in a region:
approximateFarthest[reg_, pt_] := First[Nearest[RandomPoint[reg, 10 ^ 4], pt, DistanceFunction -> (-Norm[#1 - #2]&)]]Find the farthest point on a region from a given point:
ℛ = 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}]}]Properties & Relations (6)
RandomPoint will generate points with uniform density:
ℛ = Disk[];pts = RandomPoint[ℛ, 10 ^ 5];Histogram3D[pts]Choosing random coordinate points from a region of points:
pts = RandomReal[1, {1000, 2}];ℛ = Point[pts];rp = RandomPoint[ℛ, 10 ^ 4];Corresponds to RandomChoice of coordinate points:
rc = RandomChoice[pts, 10 ^ 4];Histogram3D /@ {rp, rc}Choosing random points from a Cuboid region:
bounds = {{-1, 1}, {-1, 1}, {-1, 1}};ℛ = Cuboid@@Transpose[bounds];rp = RandomPoint[ℛ, 5000];Corresponds to RandomVariate of a UniformDistribution:
rv = RandomVariate[UniformDistribution[bounds], 5000];Table[Graphics3D[{PointSize[Tiny], Point[p]}, Boxed -> False], {p, {rp, rv}}]Choosing random points from a Disk region:
{a, r} = {1, 3};ℛ = Disk[{a, 0}, r];rp = RandomPoint[ℛ, 10 ^ 4];Corresponds to RandomVariate of a WignerSemicircleDistribution:
rv = RandomVariate[WignerSemicircleDistribution[a, r], 10 ^ 4];Histogram /@ {rp[[All, 1]], rv}Choosing random coordinate points from a Triangle region:
{min, max, mode} = {-1, 2, 1};ℛ = Triangle[{{min, 0}, {max, 0}, {mode, 1}}];rp = RandomPoint[ℛ, 10 ^ 4];Corresponds to RandomVariate of a TriangularDistribution:
rv = RandomVariate[TriangularDistribution[{min, max}, mode], 10 ^ 4];Histogram /@ {rp[[All, 1]], rv}FindInstance can generate exact instances for special and formula regions:
FindInstance[{x, y, z}∈Sphere[{1, 1, 1}, 1 / 2], {x, y, z}]However, instances are not uniform:
ℛ = 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}Related Guides
History
Text
Wolfram Research (2015), RandomPoint, Wolfram Language function, 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: 12-June-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: 12-June-2026]}