Functions for average and variance calulations

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Functions for average and variance calulations

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

--
Von meinem Seibert gesendet

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Functions for average and variance calulations

Ulf Zibis

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.

-Ulf


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Functions for average and variance calulations

Paul B Mahol
On 7/9/19, Ulf Zibis <[hidden email]> 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
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Functions for average and variance calulations

Ulf Zibis

Am 09.07.19 um 10:06 schrieb Paul B Mahol:

> On 7/9/19, Ulf Zibis <[hidden email]> 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.

I now have developed these functions.
Maybe one has interest, so I share them.

-Ulf


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

util_statistics_1.patch (7K) Download Attachment