sanity check, 'cos I'm tired:
I've got a list of objects with a Vector3 position. I want to create a rolling mean that is updated with a new object is added to the list.
am I correct in saying that this will update the mean properly:
MeanPosition = Vector3.Lerp(MeanPosition, newObject.position, 1.0 / list.Count);
@gsuberland i fear it's just an approximation. Any reason you can't have a running sum?
@gsuberland i an not certain but I believe that earlier elements could have greater influence then later. And I don't like the constant re-normalisation of floating point values.
Runsum = vec3.sum( Runsum, newel);
Mean = vec3.Lerp( 0, Runsum, 1.0 / count);
Should be as fast.
@ekg @gsuberland why do you need Lerp for this, why not just
Mean = Runsum / count;
@ekg @gsuberland well,
Mean = Runsum * (1.0 / count);
would probably be better
@mrsbeanbag I would let the compiler decide, and write whatever is the most ergonomic.
@ekg hm tbh i wouldn't. compilers are sometimes not allowed to do "obvious" things with floating point computations. because floating point. signed a compiler engineer
@mrsbeanbag that's what --ffast-math is for. But I am more than willing to acknowledge my limited experience working with floating point math, I had to look up what Lerp was...
@ekg --ffast-math is for breaking things. and you still don't know what it's actually going to do.
@mrsbeanbag I would say: that is what testing is for. But I have never setup a proper testing infrastructure for any of the projects I have started.
Unit test should catch these errors, but you would have to set up one for every critical math function.
@ekg oh yeah we have a full suite of IEEE compliance tests. rofl
@mrsbeanbag remember to test your test.
@mrsbeanbag if you wouldn't mind, in your experience how often, and how badly does things get broken?, I have used -Ofast for as long as it has been available and never had issues, but I also avoid floating point math as the plague.
@ekg well, any time you want to do a Kahan summation or robust geometric predicates for instance
@ekg oh, I see what you mean about the running sum - store it in addition to the running mean. makes sense, thanks.