📄 weightedmean.java
字号:
## An ffmpeg and SDL TutorialPrintable version Text versionThe function we are using is a weighted mean using a geometric series as itsweights. A weighted mean is defined like this: w_0*x_0 + w_1*x_1 + ... + w_n*x_n --------------------------------- w_0 + w_1 + ... + w_n If you substitute 1 in for each w_n, you get your normal everyday arithmeticmean (a.k.a. an _average_). Our function is basically a repetition of: total = d_x + c*avg; However, you can also look at it like this: total = c^n*d_0 + c^(n-1)*d_1 + ... + c*d_(n-1) + d_n in which case, this is just the top part of a weighted mean with c^n,c^(n-1)... as the weights. That means the bottom half is c^n+c^(n-1)...,which, as you may have guessed, is a simple geometric sum which works out to1/(1-c) as n approaches infinity. So, by approximation, the weighted mean of our sequence of diffs is simply: total ------- = total * (1-c) 1 ----- (1-c) So when we get the final total and want to know the average, we just multiplyit by 1-c and get the answer! There is probably a name for this way of takingthe mean of a sequence, but I'm pretty ignorant and I don't know it. If youknow it, please email me. * * *Function Reference Data Referenceemail:dranger at gmail dot comThis work is licensed under the Creative Commons Attribution-Share Alike 2.5License. To view a copy of this license, visithttp://creativecommons.org/licenses/by-sa/2.5/ or send a letter to CreativeCommons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. Code examples are based off of FFplay, Copyright (c) 2003 Fabrice Bellard, anda tutorial by Martin Bohme.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -