A method, computer program, and arrangement for controlling milking by a milking device, wherein probability values are associated with different milking parameter settings capable of being used for the milking of a milk producing animal, a milking parameter setting is drawn from among the different milking parameter settings based on the probability values for the different milking parameter settings, a milking of the milk producing animal is controlled using the drawn milking parameter setting, a milk flow is sensed from the milk producing animal during the milking, the probability values for the different milking parameter settings are updated based on the sensed milk flow, a further milking parameter setting among the different milking parameter settings is drawn based on the updated probability values for the different milking parameter settings, and the further milking parameter setting is used to control a following milking of the milk producing animal.