Hello.
I am currently attempting to adapt existing an existing matlab code (sucessfully used to create gini coefficients using .dbf output from a histogram) to perform the same function for a simple table count in excel. The code is attached below. The purpose of this script is explained in the code itself, but the basic idea is it would convert count numbers for "income" levels into frequencies, and then perform the necessary steps to compute a Gini coefficient for that.
My aim would be to modify this script so that it can perform the same process, but for an excel table which contains similar data (one column for "income", one column for "count" of said income levels).
I have attached an excel document which contains a table - lightcount is the "income", and "count" is the frequency by which "income" value was found in the dataset. I attempted to adapt the code by simply trying to replace to_frequency(hist) with the lightcount variable name, but that produced no results.
Thank you for your time.
function freq = to_frequency(input)
a = sum(input);
totals = repmat(a,size(input,1),1);
freq = input./totals;
Code for "calculating" the gini itself
list = to_frequency(hist);
s = list.*x_values;
s = cumsum(s);
s2 = [0; s];
s = [s; 0];
s3 = s+s2;
list = [list; 0];
G = 1 - sum(list.*s3)/s2(end);
0 件のコメント
サインインしてコメントする。