Fwd: The progress bar that doesn't convey any sense of progress (was Re: ...)

Maarten Bosmans mkbosmans at gmail.com
Sun Dec 13 17:41:18 GMT 2009


I'm really sorry, but somehow I managed to send the mail without the
formula in it.
Below the full mail, but the meat of it is:

y[i] = (1 - (1-a)^c) x[i] + (1-a)^c y[i-1]

Maarten


---------- Forwarded message ----------
From: Maarten Bosmans <mkbosmans at gmail.com>
Date: 2009/12/11
Subject: Re: The progress bar that doesn't convey any sense of
progress (was Re: ...)
To: John Arbash Meinel <john at arbash-meinel.com>


2009/12/10 John Arbash Meinel <john at arbash-meinel.com>:
> Gordon Tyler wrote:
>> I think I'll try John's weighted calculation first because it sounds
>> simpler to implement. We can tweak the weighting as necessary.
>
> Low-pass filter?
> http://en.wikipedia.org/wiki/Low-pass_filter#Algorithmic_implementation
>
> If you look at the core line:
> y[i] := α * x[i] + (1-α) * y[i-1]
>
> I suppose they use an inverted alpha param. In that it signals how much
> of the new value to use, versus how much of the old value. But, same
> equation.
>
> Since our sampling rate is not fixed, we might consider varying things
> based on converting it back into a fixed sampling.

To adjust for the varying sample rate use the following:

Let c be the number of samples the new value represents. In your
example the weight was based on 0.1s samples and the new sample
arrived after 1s, so c=10, but in general c doesn't have to be
integer.

The is we suppose that during the last sample and the new sample the
download speed had the value of the new sample, the formula becomes:

y[i] = (1 - (1-a)^c) x[i] + (1-a)^c y[i-1]

For c=1 this is equal to the simpler formula, so this formula is a
generalization of it.

> eg. start by proposing an ideal 10 samples per sec (0.1s/sample). Then
> if we get a sample at 1s, you can break that into 10 mini-samples, and
> average across them. I'm sure there is a closed form solution that
> involves a couple exponentials, but I don't really feel like working out
> the math. (y[i] = a x[i] + ? x[i-1] + ? x[i-2] + ... ? y[i-10]). And
> consider that all of those x's are the same value, to get
>
> y[i] = (a + ? + ? + ?) x[i] + ...
>
> We could... actually break the tnow - tprev into steps and run the
> filter in a loop:
>
> for repeat in delta / 0.1:
>  avg = alpha * avg + (1-alpha) * cur_rate

With the above formula you don't need a loop anymore. Moreover, c can
be <1, so you can base the weight on a sampling interval 1s and when a
sample arrives in 0.4s you can just use the formula.

> Anyway, something is better than nothing, give it a shot and see if you
> like what you get.
>
> John
> =:->

Maarten



More information about the bazaar mailing list