# sm.util.geometricMedian

Numerically approximates the geometric median from a table of points.

**Kind:** Function

**Environments:** Game, Terrain

## Game

``` { .lua .api-signature }
sm.util.geometricMedian( points, initialGuess?, iterations? )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.util.md#geometricmedian)

If no initial guess is made, the mean position of all the points will be used as a guess.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `points` | table | The table of points. \{ [Vec3](../Game-Script-Environment/Userdata/Vec3.md), ... \}. |
| `initialGuess` *(optional)* | [Vec3](../Game-Script-Environment/Userdata/Vec3.md) | A guessed position to start searching from. (Optional) |
| `iterations` *(optional)* | integer | The number of iterations. (Defaults to 1) |

**Returns:**

| Type | Description |
| --- | --- |
| [Vec3](../Game-Script-Environment/Userdata/Vec3.md) | The estimated geometric median. |

## Terrain

``` { .lua .api-signature }
sm.util.geometricMedian( points, initialGuess?, iterations? )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.util.md#geometricmedian)

If no initial guess is made, the mean position of all the points will be used as a guess.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `points` | table | The table of points. \{ [Vec3](../Terrain-Script-Environment/Userdata/Vec3.md), ... \}. |
| `initialGuess` *(optional)* | [Vec3](../Terrain-Script-Environment/Userdata/Vec3.md) | A guessed position to start searching from. (Optional) |
| `iterations` *(optional)* | integer | The number of iterations. (Defaults to 1) |

**Returns:**

| Type | Description |
| --- | --- |
| [Vec3](../Terrain-Script-Environment/Userdata/Vec3.md) | The estimated geometric median. |
