floating point product expansion equivalence

后端 未结 3 1247
抹茶落季
抹茶落季 2021-01-18 10:11

In IEEE 754 floating point, it is possible that

a*(b-c) != a*b-a*c // a, b, c double

So expansion of a product is not guaranteed to be equa

3条回答
  •  死守一世寂寞
    2021-01-18 10:33

    But maybe holds the weaker assertion?:

    (1.0/n)*(b1+b2+...+bn) <= 1.0
    && (1.0/n)*b1+(1.0/n)*b2+...+(1.0/n)*bn <= 1.0
    

    No. For example, this assertion fails on my computer with n=9 and bi=1.0.

    I simply wonder if you can guarantee that the average of a data set does not exceed some value that is also not exceeded by every single data value, no matter how you compute the average (first adding and once dividing, or adding every value divided).

    Once again, the answer is no. The correlation E[(X-Xbar)*(Y-Ybar)]/(sigma_x * sigma_y) between two random variables should always be between -1.0 and 1.0. Yet if you compute the statistics for two perfectly correlated (or perfectly anti-correlated) random variables, you'll oftentimes see a correlation that is slightly greater than +1 (or slightly less than -1).

提交回复
热议问题