[FFmpeg-user] Functions for average and variance calulations

Paul B Mahol onemda at gmail.com
Tue Jul 9 11:06:39 EEST 2019


On 7/9/19, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
>
> Am 09.07.19 um 00:25 schrieb Ulf Zibis:
>> Hi,
>>
>> are there such functions in the FFmpeg library?
>>
>> I have an integer array with lets say 13 numbers (accumulated counts of
>> X in the range of 0..12) like:
>> a) 0 1 0 1 2 7 9 5 4 3 2 0 1
>> b) 7 1 9 8 1 6 2 0 0 1 9 1 0
>>
>> In a) the average X would be ~6 and the variance would be small.
>> In b) the average X would be ~3.5 and the variance would be bigger.
>>
>> I'm looking for functions that can calulate such values with a result in
>> float resolution.
>>
>> -Ulf
> For a qudratic average I could use something like:
>         float sum = 0;
>         for (int i = s->span_r -  s->span_l; i >= 0; i--)
>             sum += pow(counts[i], 2);
>         float qaverage = sqrt(sum / (s->span_r -  s->span_l + 1));
>
> But for calculating the variance I'm lost. I assume, there are already
> solutions for both in the FFmpeg lib.

No, they are not there. At least not freely available via API.
If you have formula for variance then its easy to implement it.

>
> -Ulf
>
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list