Gmail Lịch Docs Ảnh Web thêm »
Các nhóm được ghé thăm gần đây | Trợ giúp | Đăng nhập
Trang chủ Google Groups
Any way around non-reversibility of floating point ops
Hiện có quá nhiều các chủ đề trong nhóm này được đặt hiển thị đầu tiên. Để đặt chủ đề này hiển thị đầu tiên, hãy loại bỏ tuỳ chọn này khỏi chủ đề khác.
Có lỗi trong khi xử lý yêu cầu của bạn. Vui lòng thử lại.
cờ
  8 bài viết - Thu gọn tất cả  -  Dịch tất cả sang Đă dịch (Xem tất cả nội dung gốc)
Nhóm mà bạn gửi bài đến là Nhóm Usenet. Các bài viết được gửi đến nhóm này sẽ hiển thị email của bạn cho mọi người trên Internet.
Thư phản hồi của bạn chưa gửi đi được.
Bạn đă đăng bài thành công
 
Từ:
Tới:
Đồng gửi:
Trả lời cho:
Thêm Cc | Thêm Trả lời vào | Chỉnh sửa Chủ đề
Chủ đề:
Xác thực:
Để xác minh, vui ḷng nhập các kư tự bạn nh́n thấy trong h́nh bên dưới hoặc các số bạn nghe thấy khi nhấp vào biểu tượng trợ giúp truy cập. Nghe và nhập những số bạn nghe thấy
 
Peter Seibel  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 2 Tháng Mười Một 2008, 23:30
Nhom moi:sci.math.num-analysis
Từ: Peter Seibel <peter.sei...@gmail.com>
Ngày: Sun, 2 Nov 2008 08:30:20 -0800 (PST)
Địa phương: Chủ Nhật 2 Tháng Mười Một 2008 23:30
Tiêu đề: Any way around non-reversibility of floating point ops
I've got an algorithm for computing the probability of a candidate in
the presidential election winning a certain number of elector votes
that looks like this (in pseudo-code):

  define compute-ev-probabilites (state-probs)
    probs = make-array 0 .. 538
    probs[0] = 1
    foreach state-prob in state-probs
       fold-into probs state-prob.votes state-probs.probability

  define fold-into (probs votes prob)
    for i from 538 downto 0
      probs[i] = probs[i] * (1 - prob)
      if (votes <= i)
        probs[i] = probs[i] + (prob * probs[i - votes])

So far so good. Now I'd like to add this function which can back out
the effects of a single state:

  define back-out (probs votes prob)
     for i from 0 to 538
      if (= prob 1)
        probs[i] (i + votes) < probs.length ? probs[i + votes] : 0
      else
        if (votes <= i) probs[i] = probs[i] - probs[i - votes] * prob
        probs[i] = probs[i] / (1 - prob)

Mathematically this works--I've actually implemented this in Common
Lisp and when I use arbitrary-precision rational numbers it works
perfectly. But when I use floating point numbers the computations in
back-out get wildly out of whack. As best as I can tell this is
because small errors introduced because (x * y) / y isn't necessarily
exactly x get propagated throughout the whole array of probabilities
and perhaps amplified by inaccuracies in the subtraction. (I can't
just use rationals because I'm actually implementing this in
Javascript whose only numeric type is double float.)

Is there some obvious way to write this so I can still use floating
point numbers but have back-out work properly. I'd be happy to trade
some precision for reversibility.

-Peter


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Gordon Sande  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 3 Tháng Mười Một 2008, 02:13
Nhom moi:sci.math.num-analysis
Từ: Gordon Sande <g.sa...@worldnet.att.net>
Ngày: Sun, 02 Nov 2008 19:13:22 GMT
Địa phương: Thứ Hai 3 Tháng Mười Một 2008 02:13
Tiêu đề: Re: Any way around non-reversibility of floating point ops
On 2008-11-02 12:30:20 -0400, Peter Seibel <peter.sei...@gmail.com> said:

If you are doing a lot of manipulations this numers that are 1 - eps
it may pay to use a bit of symbolic smarts to keep the 1 separate from
the eps. How to do this "depends". Working through an error analysis
should tell you where it might help. You would be using the symbolic
analysis to lower the sensitivity of the computation to error progation.

However since you had to ask one suspects that you may not be familiar
with doing the error analyses. (Yet another variation on the classic
comment on the pricing of yachts!)


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Peter Seibel  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 3 Tháng Mười Một 2008, 04:38
Nhom moi:sci.math.num-analysis
Từ: Peter Seibel <peter.sei...@gmail.com>
Ngày: Sun, 2 Nov 2008 13:38:11 -0800 (PST)
Địa phương: Thứ Hai 3 Tháng Mười Một 2008 04:38
Tiêu đề: Re: Any way around non-reversibility of floating point ops
On Nov 2, 11:13 am, Gordon Sande <g.sa...@worldnet.att.net> wrote:

I'm aware only that one should do an error analysis but have no idea
how to go about it. I was just wondering if there was some well-known
simple trick for trading off precision. Sounds like not. Thanks--I'm
off to implement bignums in Javascript. ;-)

-Peter


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Thomas M. Hermann  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 3 Tháng Mười Một 2008, 06:27
Nhom moi:sci.math.num-analysis
Từ: "Thomas M. Hermann" <tmh.pub...@gmail.com>
Ngày: Sun, 2 Nov 2008 15:27:16 -0800 (PST)
Địa phương: Thứ Hai 3 Tháng Mười Một 2008 06:27
Tiêu đề: Re: Any way around non-reversibility of floating point ops
On Nov 2, 10:30 am, Peter Seibel <peter.sei...@gmail.com> wrote:

> I've got an algorithm for computing the probability of a candidate in
> the presidential election winning a certain number of elector votes
> that looks like this (in pseudo-code):

>   define compute-ev-probabilites (state-probs)
>     probs = make-array 0 .. 538
>     probs[0] = 1
>     foreach state-prob in state-probs
>        fold-into probs state-prob.votes state-probs.probability

>   define fold-into (probs votes prob)
>     for i from 538 downto 0
>       probs[i] = probs[i] * (1 - prob)

Convert this line to : probs[i] = probs[i] - probs[i] * prob

>       if (votes <= i)
>         probs[i] = probs[i] + (prob * probs[i - votes])

> So far so good. Now I'd like to add this function which can back out
> the effects of a single state:

>   define back-out (probs votes prob)
>      for i from 0 to 538
>       if (= prob 1)
>         probs[i] (i + votes) < probs.length ? probs[i + votes] : 0
>       else
>         if (votes <= i) probs[i] = probs[i] - probs[i - votes] * prob
>         probs[i] = probs[i] / (1 - prob)

Convert this line to : probs[i] = probs[i] * (1 + prob) / (1 -
prob*prob)

The little experiment I ran indicated that the roundoff errors should
cancel out with those modification.

Cheers,

Tom H.


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Peter Spellucci  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 3 Tháng Mười Một 2008, 20:06
Nhom moi:sci.math.num-analysis
Từ: spellu...@fb04373.mathematik.tu-darmstadt.de (Peter Spellucci)
Ngày: Mon, 3 Nov 2008 14:06:25 +0100 (CET)
Địa phương: Thứ Hai 3 Tháng Mười Một 2008 20:06
Tiêu đề: Re: Any way around non-reversibility of floating point ops

In article <7d6c2a14-36f5-426d-9563-b67f70e17...@a29g2000pra.googlegroups.com>,
 Peter Seibel <peter.sei...@gmail.com> writes:

as stated already by others, yuo must in principle use an error analysis based
on the (hopefully for your system ) correct model of the computer arithmetic

  (x machine operation y ) = (x exact operation y)(1+eta)

with abs(eta)<= eps = "machine precision" = 2^(-53) in double
but since vote is integer, it might suffice if you replace the test
   < i
by
  < dble(i)+0.25
?
(you compare variables which in orinciple should come out as integers,
hopefully the roundoff errors are not thta large that errors >=1 occur.)
hth
peter


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Martin Eisenberg  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 4 Tháng Mười Một 2008, 04:48
Nhom moi:sci.math.num-analysis
Từ: Martin Eisenberg <martin.eisenb...@udo.edu>
Ngày: 3 Nov 2008 21:48:40 GMT
Địa phương: Thứ Ba 4 Tháng Mười Một 2008 04:48
Tiêu đề: Re: Any way around non-reversibility of floating point ops

Thomas M. Hermann wrote:
> On Nov 2, 10:30 am, Peter Seibel <peter.sei...@gmail.com> wrote:
>>       probs[i] = probs[i] * (1 - prob)

> Convert this line to :
> probs[i] = probs[i] - probs[i] * prob
>>       probs[i] = probs[i] / (1 - prob)

> Convert this line to :
> probs[i] = probs[i] * (1 + prob) / (1 - prob*prob)
> The little experiment I ran indicated that the roundoff errors
> should cancel out with those modification.

Is that transformation in the lore or has anyone written about it?

Martin

--
Quidquid latine scriptum est, altum videtur.


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Peter Seibel  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 4 Tháng Mười Một 2008, 13:11
Nhom moi:sci.math.num-analysis
Từ: Peter Seibel <peter.sei...@gmail.com>
Ngày: Mon, 3 Nov 2008 22:11:13 -0800 (PST)
Địa phương: Thứ Ba 4 Tháng Mười Một 2008 13:11
Tiêu đề: Re: Any way around non-reversibility of floating point ops
On Nov 2, 3:27 pm, "Thomas M. Hermann" <tmh.pub...@gmail.com> wrote:

Hmmm, it didn't seem to help in my actual case. Thanks though.

-Peter


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Thomas M. Hermann  
Xem tiểu sử   Dịch sang Đă dịch (Xem Nội dung gốc)
 Các tuỳ chọn khác 5 Tháng Mười Một 2008, 08:59
Nhom moi:sci.math.num-analysis
Từ: "Thomas M. Hermann" <tmh.pub...@gmail.com>
Ngày: Tue, 4 Nov 2008 17:59:42 -0800 (PST)
Địa phương: Thứ Tư 5 Tháng Mười Một 2008 08:59
Tiêu đề: Re: Any way around non-reversibility of floating point ops
On Nov 3, 3:48 pm, Martin Eisenberg <martin.eisenb...@udo.edu> wrote:

It just something I came up with be devising a little, flawed,
experiment in javascript. I ran it on http://www.arachnoid.com/javascript/interactiveJavaScript.html

It started like this.

function roundoff_error(exact,approximate) {
  return Math.abs( approximate/exact - 1.0 );

}

function foo(x,y) {
  return x/(1-y);

}

function bar(x,y) {
  return x*(1-y);

}

function main()
{
  x=0.1;
  y=0.2;
  print("Roundoff error : " + roundoff_error(x,foo(bar(x,y),y)));

}

And the output was

Roundoff error : 2.220446049250313e-16

I think I got the idea for playing algebraic games from mucking around
in BLAS code or maybe it was something I read, regardless, I played
around with the equations until I found something that didn't exhibit
roundoff error for various x and y. The result was:

function foo(x,y)
{
return x*(1+y)/(1-y*y);

}

function bar(x,y)
{
return x-x*y;

}

I didn't want to spend a great deal of time verifying this, so I
didn't try a great number of inputs. In the process of writing this
reply, I just checked x=0.1 and y=0.22 which resulted in a roundoff
error of 1.1102230246251565e-16.

I didn't do anything formal, I was just doing a quick experiment with
some algebraic manipulation. Obviously, the quick adjective should be
replaced with flawed.

Tom H.


    Chuyển tiếp  
Bạn phải Đăng nhập trước khi đăng bài
Để đăng bài, trước tiên bạn phải tham gia vào nhóm này.
Vui lòng cập nhật biệt hiệu của bạn trên trang cài đặt đăng ký trước khi đăng.
Bạn không có quyền để đăng bài.
Kết thúc bài viết
« Quay lại Cuộc thảo luận « Chủ đề mới hơn     Chủ đề cũ hơn »

Tạo nhóm - Google Groups - Trang chủ Google - Điều khoản Dịch vụ - Chính sách bảo mật
&Bản quyền;2010 Google