K
K
kizijo2019-02-02 23:16:20
JavaScript
kizijo, 2019-02-02 23:16:20

How to calculate the coefficient of difference between numbers in a series?

There are two examples of a series of natural numbers:
1) 4 5 5 5 4 5 4 5 5 5
2) 3 10 25 4 15 40 32 9 14 19
Both there and there 10 numbers each.
In the first case, the maximum spread between the numbers is obviously small. All numbers in the series are practically equal to each other, that is, if each number is compared with each other, then the average difference between the numbers will not be more than one. You can also represent these numbers as a line on the chart - there will be an almost perfect straight line.
In the second case, the spread is obviously larger and I do not know how to calculate this average number by which each number in the series differs from the other. A very broken graph immediately appears, and in general, all this is visual if you imagine it in your head, but you need to somehow express it mathematically. Are there any options / formulas to get this coefficient, except for literally comparing each number with each other and then calculating the arithmetic mean?
Thanks :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Zuev, 2016-06-30
@denisbookreev

Although everything is fine on the codepen

In the codepen, you have all the content visible and nowhere to go display:none
Try to work around it like this
function subcatHeight() {
  var $subcategories = $('.subcategories-block'),
    $subMenu = $('.goods-menu__subcategories').css({ visibility: 'hidden', display: 'block' });

  $subcategories.each(function() {
    var $parent = $(this),
      item = $parent.find('.subcategories-block__item'),
      itemsLength = item.length,
      itemsHeight = 0,
      itemLonger = 0;

    item.each(function() {
      itemsHeight += $(this).innerHeight();

      if( $(this).innerHeight() > itemLonger )
      {
        itemLonger = $(this).innerHeight();
      }
    });

    $parent.css({
      "max-height" : itemsHeight/4 + itemLonger*0.7
    });
  });
  $subMenu.css({ visibility: '', display: '' });
}

A
ArturArturov, 2016-06-30
@ArturArturov

try this:
$(this).height()

D
Dimonchik, 2019-02-02
@kizijo

there
are statistics parameters called
median and standard deviation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question