# Random Integer Distribution

**URL:** <https://discourse.mcneel.com/t/random-integer-distribution/50330>\
**Category:** Grasshopper\
**Tags:** random\
**Created:** [November 28, 2017, 4:20pm UTC](https://discourse.mcneel.com/t/random-integer-distribution/50330 "2017-11-28T16:20:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Whitby](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ryan_whitby/32/769594_2.png) [@Ryan\_Whitby](https://discourse.mcneel.com/u/Ryan_Whitby)\
**Post date:** [November 28, 2017, 4:20pm UTC](https://discourse.mcneel.com/t/random-integer-distribution/50330/1 "2017-11-28T16:20:38Z")

</div>

Something I’ve noticed for a while is that the numbers that come out of the random component tend to avoid the limits of the domain. I’m curious as to the reason for this and what methods people use to get a more even number distribution.

 ![Canvas at 11;15;33](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/8/8/8823a7d7a04ee56cdd668d63844d50e42f626020.png)

---

<div class="post-metadata">

**Author:** ![DavidRutten](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/davidrutten/32/755688_2.png) [@DavidRutten](https://discourse.mcneel.com/u/DavidRutten)\
**Post date:** [November 28, 2017, 4:30pm UTC](https://discourse.mcneel.com/t/random-integer-distribution/50330/2 "2017-11-28T16:30:35Z")

</div>

It’s a mistake in the random component, but changing it now would cause different distributions for all existing files using these components, so I’d rather not. The problem is that it will round the integers from the floating point numbers, so every integer N within the range gets all the values from `N-0.5` to `N+0.5`, except for the first and last ones which only go from `0.0` to `0.5` and from `M-0.5` to `M` respectively.

One thing you can do is grow the range by (nearly) half a unit on either end. If you grow by a full half unit, you may get rounding errors.

 ![random](https://global.discourse-cdn.com/mcneel/original/3X/9/2/92dd83d87ac616385ce1422ff63785ffc6c59106.png)

---

<div class="post-metadata">

**Author:** ![Ryan\_Whitby](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ryan_whitby/32/769594_2.png) [@Ryan\_Whitby](https://discourse.mcneel.com/u/Ryan_Whitby)\
**Post date:** [November 28, 2017, 4:34pm UTC](https://discourse.mcneel.com/t/random-integer-distribution/50330/3 "2017-11-28T16:34:47Z")

</div>

That makes sense. Thanks!

---

<div class="post-metadata">

**Author:** ![user3180](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user3180/32/351630_2.png) [@user3180](https://discourse.mcneel.com/u/user3180)\
**Post date:** [January 11, 2022, 5:50pm UTC](https://discourse.mcneel.com/t/random-integer-distribution/50330/4 "2022-01-11T17:50:12Z")

</div>

Can i ask how did you manage to create the frequency plot? its really useful!

---

<div class="post-metadata">

**Author:** ![laurent\_delrieu](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/laurent_delrieu/32/601605_2.png) [@laurent\_delrieu](https://discourse.mcneel.com/u/laurent_delrieu)\
**Post date:** [January 11, 2022, 6:59pm UTC](https://discourse.mcneel.com/t/random-integer-distribution/50330/5 "2022-01-11T18:59:48Z")

</div>

@user3180 , just be curious

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/b/a/fba273a020a582ee76d456c3e60eaebee49bdcd7.png)  
 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/5/c/a5cc2b1a6a3e29886979368216b2b0d140a256c9.png)
