Bayesian Formula - probability calculation

Discussion in 'NZ Computing' started by will, Jan 25, 2004.

  1. will

    will Guest


    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

    (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, Jan 25, 2004
    1. Advertisements

  2. will

    Warwick Guest

    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.


    Warwick, Jan 25, 2004
    1. Advertisements

  3. will

    Adam Warner Guest

    Hi will,
    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
    min(0.99 float[ min(1 b/nbad)
    min(1 g/ngood) + min(1 b/nbad) ]))

    Adam Warner, Jan 25, 2004
  4. will

    will Guest

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


    will, Jan 25, 2004
  5. will

    Julian Visch Guest

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

    lot more complicated.
    Julian Visch, Jan 25, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.