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
Bài viết từ cuộc thảo luận Any way around non-reversibility of floating point ops
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
 
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)

> 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

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.

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