My language is PHP, but the algorithm should be quite universal.
I have an associative array (say) rating and how many times the rating has been given.
This is equal to: [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5 ]
, but the numbers I am working with are quite inefficient to convert from first form to second.
What does the algorithm mean to calculate the above numbers?
Try it out:
$ total = 0; $ Count = 0; Forex currency ($ number = $ form rating = & gt; $ instance) {$ total + = $ number * $ frequency; $ Count + = $ frequency; } $ Return total $$;
Comments
Post a Comment