pseudo code, undebugged

data re-weighting implementation with extern data