I have a set of numbers, for example.
$input = array(1, 4, 7, 4, 9, 4, 8, 6, 2, 8, 7, 7, 4, 5, 3);
I am trying to determine the importance of each number based on the following rule:
As the sequence gets longer, the numbers become less significant, and every time a number is mentioned, it improves relevance (how much it depends on its position in the sequence).
I expect something like:
Array( '4' => 90% '1' => 75% '7' => 60% .... )
So 4 is the most important, followed by 1, then 7, etc. Please note that the output is completely fabricated, but gives an indication that 4 should be the most important. I think I want some kind of linear solution.
algorithm php numbers
Lizard
source share