Cost function and weights function implementation