Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pool.js #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,27 @@ Pool.Math.radrt = function(n, target){
};


/**
* 주어진 배열안의 가장 많이 반복되는 원소를 구합니다 (최빈값)
* @since 2015-04-13 (API 1)
* @author Duduzzing <[email protected]>
* @param {Array} array
*/
Pool.Math.mode = function(array){
var num = [];
var count = [];

array.forEach(function(element, index){
if(num.indexOf(element)+1){
count[index]++;
} else if(num.indexOf(element) == -1){
num.push(element);
count.push(1);
}
});
return num[count.indexOf(Math.max.apply(null,count))];
}




Expand Down