Code for the average function

Hello everyone, I’m a little confused about the average function in freefem, and I’m wondering what the code behind this command is. Because I want to implement the average value defined in the picture below in freefem.In this image, the definition of the mean is defined with two real parameters sums of 1. I want to implement it in freefem based on the average function command code.