Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

What is the best way to divide Cross Validated/Stack Overflow/Server fault reputations into separate bins, considering reputation systems tend to be highly skewed? For example: Suppose I want a set of 64 bins - 0-250,250-500,500-100...10,000-11,000. Is there a method that takes into account the number of users that have a specific reputation wen specifying the bin limits or can I just assign arbitrary bins?

slotishtype

share|improve this question
3  
Could you provide additional context about this? E.g., do you work with ordinal data such as Likert-type item or discrete scale scores that are are highly skewed, where you want to find some kind of meaningful quantiles on the underlying scale? What's the purpose of this discretization? – chl Dec 16 '10 at 13:25
Thanks for the reply, Let me re-work the question...I am not sure of the correct way to communicate the question and the correct vocab to use... – slotishtype Dec 16 '10 at 14:29
1  
The question as it stands is clear enough (although I am wondering how you can characterize merely "ordinal" data as "skewed"). What we need is a statement of your objectives and how to determine how well any particular binning will meet them. That is, why are you binning? How can that influence the decision or action you ultimately will take based on the data? It can also help us to understand something about the data generation process: are these data a random sample of something? A convenience sample? An entire population? – whuber Dec 16 '10 at 16:48

1 Answer

One approach would be to use v-optimal histograms, which are histograms that select bin sizes in order to minimize the sum of squared errors of the representation. Another alternative is equi-depth histograms which may be useful if you'd like each bin to contain (approximately) the same number of elements.

As Whuber mentioned, it would be helpful to first identify what it is that qualifies as a "good" binning.

From the revised question, it sounds like slotishtype is looking for an equi-depth histogram. Here is some example Matlab code for computing the bins, hope this helps.

% INPUT: 
% v     input vector of values (sorted)
% n     number of bins youd like to split the data into
%
% OUTPUT: 
% domain    provides the representative value for each bin
% rep       provides the range of each bin
%

% sample input from a skewed distribution
v = sort(exprnd(1, 1000, 1));
% number of bins
n = 5;

N = length(v);
d = zeros(N, 1);

[sv ix] = sort(v);
% figure out how many elements we'll put into each bin
bin_size = round(N / n);
rep = zeros(n, 3);

s = 1;
for i = 1:n
    e = min(N, s + bin_size - 1);
    % compute the representative of this bin 
    % (I use the mean, but you could change this depending on your problem)
    rep(i, 1) = mean(sv(s:e));

    % this is just to show the range of values each bin takes on
    rep(i, 2) = min(sv(s:e));
    rep(i, 3) = max(sv(s:e));

    % d builds up a representation of the original data using the bin
    % representatives for each value (vector quantization)
    d(ix(s:e)) = rep(i, 1);

    s = e + 1;
end
domain = unique(rep(:, 1));

fprintf('Bin representative vlaues:\n');
rep

fprintf('Range of each bin:\n');
rep(:, 3) - rep(:, 2)
share|improve this answer
Thanks guys, sorry for not explaining myself more clearly. I amended the question above...see above – slotishtype Jan 20 '11 at 10:10
By the way, I would up-vote the comments but my rep is too low. – slotishtype Jan 20 '11 at 10:23
some R example code for your solution would echo far. :) – Roman Luštrik Jan 20 '11 at 10:46
@Roman Luštrik, I added some sample code in Matlab for equi-depth histograms (I'm not a regular user of R), hope this will suffice! – Nick Jan 20 '11 at 18:07
Effort is always a plus in my book. – Roman Luštrik Jan 21 '11 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.