?? weightedmean.java
字號(hào):
## 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.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -