R decimals do not sum up to 1 (ensemble weight calculation)

lydias Source

I'm trying to create exponentially weighted ensembles by using AUC scores. The goal is to have all the exponential weight sum up to 1. A list of AUC score I generated:

auc <- c(0.7624542, 0.7622197, 0.7607315, 0.7603859, 0.7603311, 0.7572016, 0.7372729, 
 0.5134265, 0.5023572, 0.5020811)

Creating a scalar:

scalar <- 1/(exp(1*auc[1]) + exp(0.9*auc[2]) +exp(0.8*auc[3]) + exp(0.7*auc[4]) 
+ exp(0.6*auc[5]) + exp(0.5*auc[6]) + exp(0.4*auc[7]) + exp(0.3*auc[8]) + exp(0.2*auc[9]) 
+ exp(0.1*auc[10]))  

Creating weights by AUC scores

weight<- c(scalar*exp(1*auc[1]) ,scalar*exp(0.9*auc[2]) 
,scalar*exp(0.8*auc[3]),scalar*exp(0.7*auc[4]) 
,scalar*exp(0.6*auc[5]) ,scalar*exp(0.5*auc[6]),scalar*exp(0.4*auc[7]) , 
scalar*exp(0.3*auc[8]) ,scalar*exp(0.2*auc[9]) 
,scalar*exp(0.1*auc[10] ))
sum(weight)

Eventually the sum(weight) should equal to 1, but I keep on getting 0.9348756.

Any help will be appreciated!


rweight

Answers

comments powered by Disqus