Adds weighted histogram function