Cost function builder. For fitting distribution. In beta stage.