src/analysis/calc_weighted_sum.rb
# As long as exp_lists is ordered the same (aka the same order for each project for each list) then it will work
As long as exp_lists is ordered the same (aka the same order for each project for each list) then it will work
As long as exp_lists is ordered the same ( aka the same order for each project for each list ) then it will work
def calc_weighted_sum(exp_lists, weights=[0.5, 1.0, 0.5])
    results = Hash.new
    exp_lists.each do |list|
        list.each do |project|
            if results[project[0]] == nil
                results[project[0]] = Array.new
            end
            results[project[0]] << (project[-3].to_f * weights[0]) + (project[-2].to_f * weights[1]) + (project[-1].to_f * weights[2])
        end
    end
    return results
end
def calc_weighted_sum ( exp_lists , weights = [ 0.5 , 1.0 , 0.5 ] ) results = Hash . new exp_lists . each do | list | list . each do | project | if results [ project [ 0 ] ] == nil results [ project [ 0 ] ] = Array . new end results [ project [ 0 ] ] << ( project [ - 3 ] . to_f * weights [ 0 ] ) + ( project [ - 2 ] . to_f * weights [ 1 ] ) + ( project [ - 1 ] . to_f * weights [ 2 ] ) end end return results end
As long as exp_lists is ordered the same (aka the same order for each project for each list) then it will work
As long as exp_lists is ordered the same ( aka the same order for each project for each list ) then it will work
exp_lists
<not_specific>
weights
<not_specific>