({{, (RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron])[spec]
gives a pseudorandom polyhedron with the specified specification spec.}, {, (RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron])[spec,k]
gives a list of k pseudorandom polyhedra.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron]) gives a (RefLink[Polyhedron, paclet:ref/Polyhedron]) drawn from a specific distribution.

(RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron]) is typically used in testing and verification of time complexity for algorithms.

Possible specifications spec include:

(RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron])[spec,{(Subscript[k, 1]),(Subscript[k, 2]),…}] gives (Subscript[k, 1])×(Subscript[k, 2])×… arrays of pseudorandom polyhedra.

(RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron]) gives a different sequence of pseudorandom polyhedra whenever you run the Wolfram Language. By using (RefLink[SeedRandom, paclet:ref/SeedRandom]), you can get a repeatable sequence.

(RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron]) has the same options as (RefLink[Polyhedron, paclet:ref/Polyhedron]) with the following additions:

With the default setting (RefLink[DataRange, paclet:ref/DataRange])->Automatic, coordinates are chosen in the range 0 to 1.

OpenersPrimaryExamplesSection(Spacer1)Examples  (17)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Generate a random convex hull polyhedron:

RandomPolyhedron[{"ConvexHull",8}]

Region[%]

Generate a list of random polyhedra:

𝒫=RandomPolyhedron[{"ConvexHull",8}, 4];

Graphics3D[{Opacity[0.5],𝒫}]

Compute the volume:

Volume /@𝒫

OpenersExampleSection1(Spacer1)Scope  (4)

OpenersExampleSubsection0(Spacer1)Basic Uses  (1)

Generate a random polyhedron with a specified property:

RandomPolyhedron["ConvexHull"]

OpenersExampleSubsection1(Spacer1)Convex Hull Polyhedra  (3)

Generate a random convex hull polyhedron:

RandomPolyhedron[{"ConvexHull", 10}]

ConvexPolyhedronQ[%]

Generate a list of random convex hull polyhedra:

RandomPolyhedron[{"ConvexHull", 20},2]

Graphics3D[{Opacity[0.5],%}]

Generate a random convex hull polyhedron from the Dirichlet distribution:

RandomPolyhedron[{"ConvexHull", DirichletDistribution[{1,2,3,4}],10}]

Uniform distribution:

RandomPolyhedron[{"ConvexHull", UniformDistribution[3],10}]

Normal distribution:

RandomPolyhedron[{"ConvexHull", MultinormalDistribution[{1,2,3},{{3.4,2.4,3.1},{2.4,3.5,4},{3.1,4,4.8}}],10}]

OpenersExampleSection2(Spacer1)Options  (2)

OpenersExampleSubsection2(Spacer1)DataRange  (1)

(RefLink[DataRange, paclet:ref/DataRange]) allows you to specify the range of vertex points to generate:

RandomPolyhedron[{"ConvexHull",5}]

PolyhedronCoordinates[%]

Specify a different range:

RandomPolyhedron[{"ConvexHull",5},DataRange->{{-1,1},{-1,1},{-1,1}}]

PolyhedronCoordinates[%]

OpenersExampleSubsection3(Spacer1)WorkingPrecision  (1)

Generate a random polyhedron using machine arithmetic:

RandomPolyhedron[{"ConvexHull",5}]

PolyhedronCoordinates[%]

Using 30 digits of precision:

RandomPolyhedron[{"ConvexHull",5},WorkingPrecision->30]

PolyhedronCoordinates[%]

OpenersExampleSection3(Spacer1)Applications  (3)

OpenersExampleSubsection4(Spacer1)Basic Uses  (2)

Random polyhedra with 10 vertex points:

Multicolumn[Table[Graphics3D[{Hue[t/20], RandomPolyhedron[{"ConvexHull",10}]},ImageSize->30,Boxed->False],{t,80}],{8,30}]

Generate random polyhedra for testing algorithms and verification of time complexity:

n =Table[Floor[10^i],{i,1,4,1/40}];

polys=Table[RandomPolyhedron[{"ConvexHull",i}],{i,n}];

AllTrue[polys,ConvexPolyhedronQ]

Time complexity for algorithms for convex polyhedra:

t=First[AbsoluteTiming[ConvexPolyhedronQ[#]]]&/@polys;

Show[{ListPlot[Transpose[{n,t}], PlotRange->All,Joined->True,AxesLabel->{"n","Time"}],Plot[Style[Evaluate[Fit[Transpose[{n,t}],{1,x},x]],Red,Dashed],{x,0,10^5}]}]

OpenersExampleSubsection5(Spacer1)Geometry Probability  (1)

Simulate random convex polyhedra and compute volumes:

polys=RandomPolyhedron[{"ConvexHull",10},10000];

volume=Volume /@polys;

Estimate distribution:

adist=EstimatedDistribution[volume,NormalDistribution[μ,σ]]

Compare its histogram to the PDF:

Show[Histogram[volume,Automatic,"PDF"],Plot[PDF[adist,x],{x,0,1},PlotStyle->Red,PlotRange->All]]

Average volume of polyhedra with 10 vertices over a unit square:

Mean[adist]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

Use (RefLink[SeedRandom, paclet:ref/SeedRandom]) to get repeatable random polyhedra:

{Graphics3D[RandomPolyhedron[{"ConvexHull",6}]],Graphics3D[RandomPolyhedron[{"ConvexHull",6}]]}

{SeedRandom[1];Graphics3D[RandomPolyhedron[{"ConvexHull",6}]],SeedRandom[1];Graphics3D[RandomPolyhedron[{"ConvexHull",6}]]}

Use (RefLink[BlockRandom, paclet:ref/BlockRandom]) to block one use of (RefLink[RandomPolyhedron, paclet:ref/RandomPolyhedron]) from affecting others:

{BlockRandom[Graphics3D[RandomPolyhedron[{"ConvexHull",6}]]], Graphics3D[RandomPolyhedron[{"ConvexHull",6}]]}

Use (RefLink[ConvexPolyhedronQ, paclet:ref/ConvexPolyhedronQ]) to check the property of a random polyhedron:

RandomPolyhedron[{"ConvexHull", 10}]

ConvexPolyhedronQ[%]

The (RefLink[OuterPolyhedron, paclet:ref/OuterPolyhedron]) of a random polyhedron is simple:

𝒫=RandomPolyhedron[{"ConvexHull", 10}]

SimplePolyhedronQ[OuterPolyhedron[𝒫]]

Random polyhedra do not have voids:

InnerPolyhedron[𝒫]

Using (RefLink[PolyhedronDecomposition, paclet:ref/PolyhedronDecomposition]) to decompose a polyhedron into tetrahedra:

RandomPolyhedron[{"ConvexHull", 6}]

PolyhedronDecomposition[%,"Tetrahedron"]

Graphics3D[{FaceForm[Black],EdgeForm[{Thick,White}],%}]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

Random polyhedron collections:

Graphics3D[{Opacity[0.5],Table[{EdgeForm[Black],Hue[RandomReal[]],RandomPolyhedron[{"ConvexHull",10}]},{15}]}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Polyhedron, paclet:ref/Polyhedron])  ▪  (RefLink[RandomPoint, paclet:ref/RandomPoint])  ▪  (RefLink[RandomReal, paclet:ref/RandomReal])  ▪  (RefLink[SeedRandom, paclet:ref/SeedRandom])  ▪  (RefLink[ConvexPolyhedronQ, paclet:ref/ConvexPolyhedronQ])  ▪  (RefLink[SimplePolyhedronQ, paclet:ref/SimplePolyhedronQ])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Polyhedra, paclet:guide/Polyhedra])}})}})