Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > NZ Computing > Bayesian Formula - probability calculation

Reply
Thread Tools

Bayesian Formula - probability calculation

 
 
will
Guest
Posts: n/a
 
      01-25-2004
hi,

can i please have some pointers to calculate the 'spamicity'?

i've read a couple of websites, but most of them are using it in a
programming language way, rather than a formulae.

eg this from www.paulgraham.com

(let ((g (* 2 (or (gethash word good) 0)))
(b (or (gethash word bad) 0)))
(unless (< (+ g b) 5)
(max .01
(min .99 (float (/ (min 1 (/ b nbad))
(+ (min 1 (/ g ngood))
(min 1 (/ b nbad)))))))))


what does it mean in simple english?

thanks

will.
 
Reply With Quote
 
 
 
 
Warwick
Guest
Posts: n/a
 
      01-25-2004
On Sun, 25 Jan 2004 17:34:44 +1300, will wrote:

> hi,
>
> can i please have some pointers to calculate the 'spamicity'?
>
> i've read a couple of websites, but most of them are using it in a
> programming language way, rather than a formulae.
>
> eg this from www.paulgraham.com
>
> (let ((g (* 2 (or (gethash word good) 0)))
> (b (or (gethash word bad) 0)))
> (unless (< (+ g b) 5)
> (max .01
> (min .99 (float (/ (min 1 (/ b nbad))
> (+ (min 1 (/ g ngood))
> (min 1 (/ b nbad)))))))))
>
>
> what does it mean in simple english?
>
> thanks
>
> will.


Byes formaula calculates the new probability of something being true (p')
given an old probability (p) + some new new evidence. The new evidence is
expressed as a probability as well. In the formula it is expressed as Py
and Pn - probability of yes and probabilty of no.

the formula is p' = 100 * Py * p / Py * p + Pn(100-p).

worked example. Probability of Mainlander being a miserable bastard is
estimated at 10% (p).
10 new posts then suggest the odds of Mainlander being a miserable bastard
are 90%.
Therefore Py = 90 and Pn = 10.

Our revised probablity of our hypothesis is then
100 * 90 * 10 / 90 * 10 + 10*(100-10) = 50

If you had another indicator you would make p' p and do it again.


HTH

Warwick



 
Reply With Quote
 
 
 
 
Adam Warner
Guest
Posts: n/a
 
      01-25-2004
Hi will,

> hi,
>
> can i please have some pointers to calculate the 'spamicity'?
>
> i've read a couple of websites, but most of them are using it in a
> programming language way, rather than a formulae.
>
> eg this from www.paulgraham.com
>
> (let ((g (* 2 (or (gethash word good) 0)))
> (b (or (gethash word bad) 0)))
> (unless (< (+ g b) 5)
> (max .01
> (min .99 (float (/ (min 1 (/ b nbad))
> (+ (min 1 (/ g ngood))
> (min 1 (/ b nbad)))))))))
>
>
> what does it mean in simple english?


Will, that is an extract of Common Lisp. (gethash word good) is looking up
the word in the group of good words. If it's not found the second part of
the OR is computed which then returns 0. Ditto for (gethash word bad) except
the word is looked up in the group of bad words.

UNLESS means to do something unless the test is true.

MAX and MIN find the maximum or minimum of a set of numbers.

FLOAT converts a number into a floating point representation.

/ is division.

+ is addition.

Everything is in prefix format, e.g. (+ 1 (* 2 3)) = (+ 1 6) = 7. It's like
function calls where the opening bracket is before the function name instead
of directly after the function name, e.g. sqrt(x) in many other languages
would be written as (sqrt x) in Lisp.

This pseudocode translation may help:

let good-entry = is the word in the group of good words?
bad-entry = is the word in the group of bad words?
g = if good-entry then choose the good-entry else 0
b = if bad-entry then choose the bad-entry else 0
unless (g+b) < 5
max(0.01
min(0.99 float[ min(1 b/nbad)
--------------------------------
min(1 g/ngood) + min(1 b/nbad) ]))

Regards,
Adam
 
Reply With Quote
 
will
Guest
Posts: n/a
 
      01-25-2004

> This pseudocode translation may help:
>
> let good-entry = is the word in the group of good words?
> bad-entry = is the word in the group of bad words?
> g = if good-entry then choose the good-entry else 0
> b = if bad-entry then choose the bad-entry else 0
> unless (g+b) < 5
> max(0.01
> min(0.99 float[ min(1 b/nbad)
> --------------------------------
> min(1 g/ngood) + min(1 b/nbad) ]))




#### hmmm.. thanks. so how is the result related to the Bayesian
formula? is the above code doing the same job as the Bayesian formula?

thanks

will.
 
Reply With Quote
 
Julian Visch
Guest
Posts: n/a
 
      01-25-2004
will wrote:

>>This pseudocode translation may help:
>>
>>let good-entry = is the word in the group of good words?
>> bad-entry = is the word in the group of bad words?
>> g = if good-entry then choose the good-entry else 0
>> b = if bad-entry then choose the bad-entry else 0
>> unless (g+b) < 5
>> max(0.01
>> min(0.99 float[ min(1 b/nbad)
>> --------------------------------
>> min(1 g/ngood) + min(1 b/nbad) ]))
>>

>
>
>
> #### hmmm.. thanks. so how is the result related to the Bayesian
> formula? is the above code doing the same job as the Bayesian formula?


P(a|b)=P(b|a)P(a) is the bayesian formula in its simplest form, gets a
----------
P(b)

lot more complicated.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Heat_Index calculation in my C program; question about formula Barry L. Bond C Programming 26 11-17-2008 04:36 PM
Again in english: Problem with probability formula for gaming logic Andreas Schmitt C++ 2 08-04-2005 04:43 PM
Bayesian RSS feed aggregator Mike HTML 0 11-17-2004 08:28 PM
Bayesian RSS feed aggregator mlavespere@hotmail.com XML 0 11-17-2004 08:18 PM
margin calculation formula/method for writing options? Deepak Computer Information 2 10-27-2003 05:51 AM



Advertisments