This function calculates the difference between two given numeric vectors while adding a penalty term (weight) to account for the number of models/instances that each vector's values were calculated from. Thus, if the models/instances are disproportionate and a penalty is included, the difference vector's values will be changed accordingly to reflect that.
get_vector_diff(vec1, vec2, m1 = 1, m2 = 1, penalty = 0)
vec1 | numeric vector |
---|---|
vec2 | numeric vector |
m1 | integer > 0 |
m2 | integer > 0 |
penalty | value between 0 and 1 (inclusive). A value of 0 means no
penalty ( |
the vector of differences between the two given vectors based on the formula: $$(vec1 - vec2) * w$$, where \(w = (min(m1,m2)/max(m1,m2))^p\) and \(p = penalty\).
See also related StackOverflow question.
If vec1
has names
, the returned vector will have the same names
attribute as vec1
.