---
title: "RandomPolyhedron"
language: "en"
type: "Symbol"
summary: "RandomPolyhedron[spec] gives a pseudorandom polyhedron with the specified specification spec. RandomPolyhedron[spec, k] gives a list of k pseudorandom polyhedra."
keywords: 
- random convex polygon
- random simple polygon
- random star-shaped polygon
- region instances
- region polygons
- random polygons
canonical_url: "https://reference.wolfram.com/language/ref/RandomPolyhedron.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Polyhedra"
    link: "https://reference.wolfram.com/language/guide/Polyhedra.en.md"
related_functions: 
  - 
    title: "Polyhedron"
    link: "https://reference.wolfram.com/language/ref/Polyhedron.en.md"
  - 
    title: "RandomPolygon"
    link: "https://reference.wolfram.com/language/ref/RandomPolygon.en.md"
  - 
    title: "RandomPoint"
    link: "https://reference.wolfram.com/language/ref/RandomPoint.en.md"
  - 
    title: "RandomReal"
    link: "https://reference.wolfram.com/language/ref/RandomReal.en.md"
  - 
    title: "SeedRandom"
    link: "https://reference.wolfram.com/language/ref/SeedRandom.en.md"
  - 
    title: "ConvexPolyhedronQ"
    link: "https://reference.wolfram.com/language/ref/ConvexPolyhedronQ.en.md"
  - 
    title: "SimplePolyhedronQ"
    link: "https://reference.wolfram.com/language/ref/SimplePolyhedronQ.en.md"
---
# RandomPolyhedron

RandomPolyhedron[spec] gives a pseudorandom polyhedron with the specified specification spec.

RandomPolyhedron[spec, k] gives a list of k pseudorandom polyhedra.

## Details and Options

* ``RandomPolyhedron`` gives a ``Polyhedron`` drawn from a specific distribution.

* ``RandomPolyhedron`` is typically used in testing and verification of time complexity for algorithms.

* Possible specifications ``spec`` include:

[image]	{"ConvexHull", ``dist``, ``n``}	convex hull of ``n`` random points from the distribution ``dist``

* ``RandomPolyhedron[{"ConvexHull", n}]`` gives the convex hull of ``n`` random points from the uniform distribution ``UniformDistribution[3]`` over the unit square.

* ``RandomPolyhedron[spec, {k1, k2, …}]`` gives ``k1×k2×…`` arrays of pseudorandom polyhedra.

* ``RandomPolyhedron`` gives a different sequence of pseudorandom polyhedra whenever you run the Wolfram Language. By using ``SeedRandom``, you can get a repeatable sequence.

* ``RandomPolyhedron`` has the same options as ``Polyhedron`` with the following additions: []

|                   |                  |                                        |
| ----------------- | ---------------- | -------------------------------------- |
| DataRange         | Automatic        | the range of vertex points to generate |
| WorkingPrecision  | MachinePrecision | precision of vertex points             |

* With the default setting ``DataRange -> Automatic``, coordinates are chosen in the range 0 to 1.

### List of all options

|                          |                  |                                        |
| ------------------------ | ---------------- | -------------------------------------- |
| DataRange                | Automatic        | the range of vertex points to generate |
| VertexColors             | Automatic        | vertex colors to be interpolated       |
| VertexNormals            | Automatic        | effective vertex normals for shading   |
| VertexTextureCoordinates | None             | coordinates for textures               |
| WorkingPrecision         | MachinePrecision | precision of vertex points             |

---

## Examples (17)

### Basic Examples (2)

Generate a random convex hull polyhedron:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 8}]

Out[1]= DynamicModule[«3»]

In[2]:= Region[%]

Out[2]= [image]
```

---

Generate a list of random polyhedra:

```wl
In[1]:= \[ScriptCapitalP] = RandomPolyhedron[{"ConvexHull", 8}, 4];

In[2]:= Graphics3D[{Opacity[0.5], \[ScriptCapitalP]}]

Out[2]= [image]
```

Compute the volume:

```wl
In[3]:= Volume  /@ \[ScriptCapitalP]

Out[3]= {0.0878853, 0.163852, 0.0864991, 0.0803078}
```

### Scope (4)

#### Basic Uses (1)

Generate a random polyhedron with a specified property:

```wl
In[1]:= RandomPolyhedron["ConvexHull"]

Out[1]=
Polyhedron[{{0.1644608504566809, 0.0576655012933307, 0.27807738523439096}, 
  {0.6892418949542443, 0.3653774940930272, 0.9244143257210506}, 
  {0.36120619041829993, 0.15314145132739232, 0.3039274962315457}, 
  {0.8823598034224991, 0.884107546487219 ... .3564151987286648, 0.7542929123933215, 0.9243473921740035}}, 
 {{10, 4, 5}, {4, 10, 8}, {4, 6, 3}, {8, 10, 2}, {6, 2, 3}, {4, 8, 6}, {2, 1, 3}, {1, 9, 3}, 
  {4, 9, 5}, {9, 1, 5}, {7, 1, 2}, {6, 8, 2}, {1, 7, 5}, {7, 2, 5}, {2, 10, 5}, {9, 4, 3}}]
```

#### Convex Hull Polyhedra (3)

Generate a random convex hull polyhedron:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 10}]

Out[1]=
Polyhedron[{{0.9559465662287072, 0.6666381414558287, 0.8590482411151892}, 
  {0.07416513665909874, 0.6620118718508685, 0.7501214996199692}, 
  {0.880731804693744, 0.670684436527837, 0.1260924646996211}, 
  {0.3249513034353, 0.548233559439733, 0.949 ... 4340879534251285}, 
  {0.2233372187804561, 0.018661225113504987, 0.9277530908561402}}, 
 {{9, 6, 5}, {2, 7, 3}, {6, 1, 5}, {2, 4, 7}, {2, 6, 9}, {6, 2, 8}, {7, 4, 9}, {4, 2, 9}, 
  {2, 3, 8}, {3, 7, 1}, {7, 9, 1}, {3, 1, 8}, {1, 6, 8}, {1, 9, 5}}]

In[2]:= ConvexPolyhedronQ[%]

Out[2]= True
```

---

Generate a list of random convex hull polyhedra:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 20}, 2]

Out[1]=
{Polyhedron[CompressedData["«557»"], 
 {{11, 8, 14}, {13, 10, 6}, {1, 13, 2}, {7, 3, 5}, {13, 12, 10}, {12, 7, 4}, {7, 5, 15}, 
  {9, 8, 11}, {8, 5, 14}, {13, 11, 2}, {7, 12, 3}, {12, 13, 3}, {13, 1, 3}, {5, 8, 15}, {8, 4, 15}, 
  {8, 9, 10}, {8, 1 ... }, 
  {13, 6, 2}, {12, 13, 11}, {5, 1, 3}, {9, 2, 15}, {2, 10, 15}, {13, 2, 7}, {2, 9, 7}, {15, 10, 1}, 
  {7, 9, 12}, {1, 5, 14}, {15, 1, 12}, {9, 15, 4}, {1, 10, 3}, {15, 12, 8}, {5, 12, 14}, 
  {12, 1, 14}, {15, 8, 4}, {8, 12, 4}, {12, 9, 4}}]}

In[2]:= Graphics3D[{Opacity[0.5], %}]

Out[2]= [image]
```

---

Generate a random convex hull polyhedron from the Dirichlet distribution:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", DirichletDistribution[{1, 2, 3, 4}], 10}]

Out[1]=
Polyhedron[{{0.1695000386281424, 0.06261286399651089, 0.4496952985269466}, 
  {0.010605742660041866, 0.061153470236312235, 0.6269242561604593}, 
  {0.024113177479867492, 0.08868058714578389, 0.2838537415046952}, 
  {0.27505826485767626, 0.211506797 ... 0.38741053760236366, 0.09835120799247891}, 
  {0.2648246393513882, 0.2107753118354351, 0.3528945241723271}}, 
 {{5, 7, 4}, {2, 7, 6}, {7, 5, 6}, {1, 2, 3}, {7, 2, 8}, {2, 1, 8}, {5, 1, 3}, {1, 5, 4}, 
  {5, 3, 6}, {3, 2, 6}, {1, 4, 8}, {4, 7, 8}}]
```

Uniform distribution:

```wl
In[2]:= RandomPolyhedron[{"ConvexHull", UniformDistribution[3], 10}]

Out[2]=
Polyhedron[{{0.7842348323342234, 0.909460232669896, 0.4265003495344466}, 
  {0.3955963299307961, 0.1403026317295586, 0.8304057603340718}, 
  {0.9697650614706879, 0.6004543643617251, 0.9912637729635183}, 
  {0.3907155739661865, 0.8990224677507095, 0 ...  0.8045559233311754}, 
  {0.3482115620985513, 0.541245983698009, 0.8314134174130341}}, 
 {{3, 6, 9}, {1, 7, 4}, {6, 5, 9}, {1, 3, 7}, {8, 3, 2}, {7, 6, 4}, {6, 1, 4}, {3, 1, 6}, 
  {7, 3, 8}, {6, 7, 5}, {7, 8, 5}, {5, 3, 9}, {3, 5, 2}, {5, 8, 2}}]
```

Normal distribution:

```wl
In[3]:= RandomPolyhedron[{"ConvexHull", MultinormalDistribution[{1, 2, 3}, {{3.4, 2.4, 3.1}, {2.4, 3.5, 4}, {3.1, 4, 4.8}}], 10}]

Out[3]=
Polyhedron[{{-2.148119493401384, -0.32297839175634024, 0.5218138277606355}, 
  {0.11604495891640387, 2.798757000946942, 3.9303252762297465}, 
  {-0.8826963221744326, 1.3506766590239105, 1.534230036966453}, 
  {2.6816203753210703, -0.287811099674326 ... 39, 2.8282477794607863, 
   4.088504929130151}, {2.2783064688540495, 4.160812275559307, 5.441558911915026}}, 
 {{6, 7, 3}, {7, 8, 4}, {7, 6, 8}, {3, 7, 5}, {7, 4, 5}, {8, 2, 4}, {2, 1, 4}, {6, 2, 8}, 
  {1, 2, 3}, {2, 6, 3}, {4, 3, 5}, {1, 3, 4}}]
```

### Options (2)

#### DataRange (1)

``DataRange`` allows you to specify the range of vertex points to generate:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 5}]

Out[1]=
Polyhedron[{{0.2772017233596251, 0.6940423220401841, 0.5967191881684619}, 
  {0.4407567696225263, 0.17842320933135913, 0.39717736350237587}, 
  {0.23091893824863985, 0.1207561034049982, 0.9729061493048194}, 
  {0.4248553317057564, 0.40247683339930096, 0.3889061955209503}, 
  {0.31116254142678157, 0.21986881412974713, 0.35143856419510744}}, 
 {{1, 3, 4}, {4, 5, 1}, {1, 5, 3}, {3, 5, 2}, {5, 4, 2}, {4, 3, 2}}]

In[2]:= PolyhedronCoordinates[%]

Out[2]= {{0.277202, 0.694042, 0.596719}, {0.440757, 0.178423, 0.397177}, {0.230919, 0.120756, 0.972906}, {0.424855, 0.402477, 0.388906}, {0.311163, 0.219869, 0.351439}}
```

Specify a different range:

```wl
In[3]:= RandomPolyhedron[{"ConvexHull", 5}, DataRange -> {{-1, 1}, {-1, 1}, {-1, 1}}]

Out[3]=
Polyhedron[{{0.5288291272080585, 1., 0.7699945099666405}, {0.2854616896607718, -0.4736885313252568, 
   -0.8536304868827196}, {1.0000000000000002, 0.6709296250040482, 0.20044836550698397}, 
  {-1., -1., -0.9999999999999999}, {0.19174093367143796, -0.1162031272217392, 1.0000000000000004}}, 
 {{1, 3, 4}, {4, 5, 1}, {1, 5, 3}, {3, 5, 2}, {5, 4, 2}, {4, 3, 2}}]

In[4]:= PolyhedronCoordinates[%]

Out[4]= {{0.528829, 1., 0.769995}, {0.285462, -0.473689, -0.85363}, {1., 0.67093, 0.200448}, {-1., -1., -1.}, {0.191741, -0.116203, 1.}}
```

#### WorkingPrecision (1)

Generate a random polyhedron using machine arithmetic:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 5}]

Out[1]=
Polyhedron[{{0.2012093445330243, 0.12600162901259848, 0.0325886848025021}, 
  {0.4491831776752655, 0.3899156930205543, 0.16431217189024605}, 
  {0.37753961841721306, 0.7757388776423659, 0.44258078326195793}, 
  {0.36039963742617354, 0.23552468857741204, 0.9723021915841052}}, 
 {{3, 1, 4}, {1, 3, 2}, {3, 4, 2}, {4, 1, 2}}]

In[2]:= PolyhedronCoordinates[%]

Out[2]= {{0.201209, 0.126002, 0.0325887}, {0.449183, 0.389916, 0.164312}, {0.37754, 0.775739, 0.442581}, {0.3604, 0.235525, 0.972302}}
```

Using 30 digits of precision:

```wl
In[3]:= RandomPolyhedron[{"ConvexHull", 5}, WorkingPrecision -> 30]

Out[3]=
Polyhedron[{{0.1673284507349999706930437069276301303423723820947108010008`30., 
   0.5044411185462336066937172654585216812457478039373379695171`30., 
   0.1446134735928127473485691663959801685910841419539849521001`30.}, 
  {0.6644203893615020632712 ... 119232241802987278642299152193`30., 
   0.5944655815414335639731133148477847270119769187267758328466`30., 
   0.7720625823337547247577004403576050655687088669592857078944`30.}}, 
 {{3, 5, 4}, {2, 5, 3}, {2, 3, 1}, {3, 4, 1}, {4, 5, 1}, {5, 2, 1}}]

In[4]:= PolyhedronCoordinates[%]

Out[4]= {{0.167328450734999970693043706928, 0.504441118546233606693717265459, 0.144613473592812747348569166396}, {0.664420389361502063271231717548, 0.732935930137611623123796876762, 0.103150172809970177981689819801}, {0.883564956473461394361314405776, 0.19 ... 161, 0.100437481650452884045227918415}, {0.392737664300852476925341614831, 0.191060275925024688347543260460, 0.226964554262840929114550352752}, {0.529194589342543704461506479012, 0.594465581541433563973113314848, 0.772062582333754724757700440358}}
```

### Applications (3)

#### Basic Uses (2)

Random polyhedra with 10 vertex points:

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

Out[1]=
|         |         |         |         |         |         |         |         |         |         |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |    |
| :------ | :------ | :------ | :------ | :--- ...  "" | "" | "" | "" | "" | "" | "" | "" | "" |
| [image] | [image] | [image] | [image] | [image] | [image] | [image] | [image] | [image] | [image] | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" | "" |
```

---

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

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

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

In[3]:= AllTrue[polys, ConvexPolyhedronQ]

Out[3]= True
```

Time complexity for algorithms for convex polyhedra:

```wl
In[4]:= t = First[AbsoluteTiming[ConvexPolyhedronQ[#]]]& /@ polys;

In[5]:= 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}]}]

Out[5]= [image]
```

#### Geometry Probability (1)

Simulate random convex polyhedra and compute volumes:

```wl
In[1]:= polys = RandomPolyhedron[{"ConvexHull", 10}, 10000];

In[2]:= volume = Volume  /@ polys;
```

Estimate distribution:

```wl
In[3]:= adist = EstimatedDistribution[volume, NormalDistribution[μ, σ]]

Out[3]= NormalDistribution[0.151653, 0.0516934]
```

Compare its histogram to the PDF:

```wl
In[4]:= Show[Histogram[volume, Automatic, "PDF"], Plot[PDF[adist, x], {x, 0, 1}, PlotStyle -> Red, PlotRange -> All]]

Out[4]= [image]
```

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

```wl
In[5]:= Mean[adist]

Out[5]= 0.151653
```

### Properties & Relations (5)

Use ``SeedRandom`` to get repeatable random polyhedra:

```wl
In[1]:= {Graphics3D[RandomPolyhedron[{"ConvexHull", 6}]], Graphics3D[RandomPolyhedron[{"ConvexHull", 6}]]}

Out[1]= {[image], [image]}

In[2]:= {SeedRandom[1];Graphics3D[RandomPolyhedron[{"ConvexHull", 6}]], SeedRandom[1];Graphics3D[RandomPolyhedron[{"ConvexHull", 6}]]}

Out[2]= {[image], [image]}
```

---

Use ``BlockRandom`` to block one use of ``RandomPolyhedron`` from affecting others:

```wl
In[1]:= {BlockRandom[Graphics3D[RandomPolyhedron[{"ConvexHull", 6}]]], Graphics3D[RandomPolyhedron[{"ConvexHull", 6}]]}

Out[1]= {[image], [image]}
```

---

Use ``ConvexPolyhedronQ`` to check the property of a random polyhedron:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 10}]

Out[1]=
Polyhedron[{{0.9085722756830463, 0.7906604027201505, 0.5632795767720775}, 
  {0.6425982920524409, 0.03418060808310641, 0.042634179271897166}, 
  {0.03810726630791539, 0.7439761897765536, 0.2527788471472383}, 
  {0.9992527337113934, 0.01425708314686 ... 1189975016856395}, 
  {0.7405264938152409, 0.06575404650166572, 0.09963669573038181}}, 
 {{1, 3, 5}, {3, 8, 5}, {3, 1, 7}, {1, 4, 6}, {5, 8, 4}, {4, 2, 6}, {1, 5, 4}, {4, 8, 2}, 
  {8, 3, 2}, {2, 1, 9}, {1, 2, 7}, {2, 3, 7}, {1, 6, 9}, {6, 2, 9}}]

In[2]:= ConvexPolyhedronQ[%]

Out[2]= True
```

---

The ``OuterPolyhedron`` of a random polyhedron is simple:

```wl
In[1]:= \[ScriptCapitalP] = RandomPolyhedron[{"ConvexHull", 10}]

Out[1]=
Polyhedron[{{0.9133539162744546, 0.8014100561494608, 0.267459275616281}, 
  {0.513259477699826, 0.7682391265106989, 0.9819696704313037}, 
  {0.6470764907178868, 0.14595948646641488, 0.6980826698269336}, 
  {0.9161601528765704, 0.7393930181249131, 0 ... 0.13664443081314137, 0.7921953174450944}, 
  {0.5222250136858573, 0.8828041611033057, 0.19985874445579133}}, 
 {{4, 6, 2}, {6, 1, 8}, {1, 5, 8}, {1, 6, 4}, {1, 4, 3}, {5, 2, 8}, {5, 1, 3}, {5, 3, 7}, 
  {3, 2, 7}, {3, 4, 2}, {2, 6, 8}, {2, 5, 7}}]

In[2]:= SimplePolyhedronQ[OuterPolyhedron[\[ScriptCapitalP]]]

Out[2]= True
```

Random polyhedra do not have voids:

```wl
In[3]:= InnerPolyhedron[\[ScriptCapitalP]]

Out[3]= EmptyRegion[3]
```

---

Using ``PolyhedronDecomposition`` to decompose a polyhedron into tetrahedra:

```wl
In[1]:= RandomPolyhedron[{"ConvexHull", 6}]

Out[1]=
Polyhedron[{{0.029486368530434293, 0.5941506740822513, 0.0050686153325820715}, 
  {0.6095715450497847, 0.5833432384241031, 0.4759672504209629}, 
  {0.7623140590663309, 0.5986522724465706, 0.357806175570885}, 
  {0.3192049708232352, 0.8082690314176706, 0.382977039100723}, 
  {0.9503630412223025, 0.7658913773764289, 0.708238407004198}, 
  {0.05889827037622064, 0.6649667660572409, 0.48978061159114294}}, 
 {{1, 3, 2}, {2, 3, 5}, {1, 2, 6}, {2, 5, 6}, {3, 1, 4}, {5, 3, 4}, {5, 4, 6}, {4, 1, 6}}]

In[2]:= PolyhedronDecomposition[%, "Tetrahedron"]

Out[2]=
{Polyhedron[{{0.029486368530434293, 0.5941506740822513, 0.0050686153325820715}, 
  {0.6095715450497847, 0.5833432384241031, 0.4759672504209629}, 
  {0.7623140590663309, 0.5986522724465706, 0.357806175570885}, 
  {0.3192049708232352, 0.8082690314176 ... }, 
  {0.05889827037622064, 0.6649667660572409, 0.48978061159114294}, 
  {0.9503630412223025, 0.7658913773764289, 0.708238407004198}, 
  {0.3192049708232352, 0.8082690314176706, 0.382977039100723}}, 
 {{3, 2, 1}, {2, 3, 4}, {3, 1, 4}, {1, 2, 4}}]}

In[3]:= Graphics3D[{FaceForm[Black], EdgeForm[{Thick, White}], %}]

Out[3]= [image]
```

### Neat Examples (1)

Random polyhedron collections:

```wl
In[1]:= Graphics3D[{Opacity[0.5], Table[{EdgeForm[Black], Hue[RandomReal[]], RandomPolyhedron[{"ConvexHull", 10}]}, {15}]}]

Out[1]= [image]
```

## See Also

* [`Polyhedron`](https://reference.wolfram.com/language/ref/Polyhedron.en.md)
* [`RandomPolygon`](https://reference.wolfram.com/language/ref/RandomPolygon.en.md)
* [`RandomPoint`](https://reference.wolfram.com/language/ref/RandomPoint.en.md)
* [`RandomReal`](https://reference.wolfram.com/language/ref/RandomReal.en.md)
* [`SeedRandom`](https://reference.wolfram.com/language/ref/SeedRandom.en.md)
* [`ConvexPolyhedronQ`](https://reference.wolfram.com/language/ref/ConvexPolyhedronQ.en.md)
* [`SimplePolyhedronQ`](https://reference.wolfram.com/language/ref/SimplePolyhedronQ.en.md)

## Related Guides

* [`Polyhedra`](https://reference.wolfram.com/language/guide/Polyhedra.en.md)

## History

* [Introduced in 2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)