# Finding difference in a number range

**URL:** <https://www.ruby-forum.com/t/finding-difference-in-a-number-range/175461>\
**Category:** Ruby\
**Created:** [September 14, 2009, 10:37am UTC](https://www.ruby-forum.com/t/finding-difference-in-a-number-range/175461 "2009-09-14T10:37:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 14, 2009, 10:37am UTC](https://www.ruby-forum.com/t/finding-difference-in-a-number-range/175461/1 "2009-09-14T10:37:47Z")

</div>

This is my problem. I have a scale from 0 to 15 and five different  
elements with their own position on that scale. How can I understand if  
they are spread all over the scale, have different positions on the  
scale, or if they are close and nearby each-other?

These are close: 2,3,4,3,2

These are not so close: 2,4,3,12,15

These are spread: 0,5,8,12,15

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 14, 2009, 10:40am UTC](https://www.ruby-forum.com/t/finding-difference-in-a-number-range/175461/2 "2009-09-14T10:40:57Z")

</div>

2009/9/14 Pål Bergström [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> This is my problem. I have a scale from 0 to 15 and five different  
> elements with their own position on that scale. How can I understand if  
> they are spread all over the scale, have different positions on the  
> scale, or if they are close and nearby each-other?
> 
> These are close: 2,3,4,3,2
> 
> These are not so close: 2,4,3,12,15
> 
> These are spread: 0,5,8,12,15

Sounds like a use case for

> **[Standard deviation](https://en.wikipedia.org/wiki/Standard_deviation)**
>
> In statistics, the standard deviation is a measure of the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the values are spread out over a wider range.
> Standard deviation may be abbreviated SD, and is most commonly represented in mathematical texts and equations by the lower case Greek letter σ (sigma), for the populat...

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 14, 2009, 10:46am UTC](https://www.ruby-forum.com/t/finding-difference-in-a-number-range/175461/3 "2009-09-14T10:46:30Z")

</div>

Robert K. wrote:

> Sounds like a use case for  
> [Standard deviation - Wikipedia](http://en.wikipedia.org/wiki/Standard_deviation)
> 
> Kind regards
> 
> robert

Never heard of that term. Great to know. Thanks. Still need to solve my  
problem, but now I know what to search for.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 14, 2009, 12:51pm UTC](https://www.ruby-forum.com/t/finding-difference-in-a-number-range/175461/4 "2009-09-14T12:51:05Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> Never heard of that term. Great to know. Thanks. Still need to solve my  
> problem, but now I know what to search for.

Found the answer:

[http://samdorr.net/blog/2008/10/standard-deviation/](http://samdorr.net/blog/2008/10/standard-deviation/)

[http://warrenseen.com/blog/2006/03/13/how-to-calculate-standard-deviation/](http://warrenseen.com/blog/2006/03/13/how-to-calculate-standard-deviation/)
