Problem with Precision floating point operation in C

前端 未结 6 1922
执笔经年
执笔经年 2021-01-31 21:03

For one of my course project I started implementing \"Naive Bayesian classifier\" in C. My project is to implement a document classifier application (especially Spam) using huge

6条回答
  •  别那么骄傲
    2021-01-31 21:26

    Try computing the inverse 1/p. That gives you an equation of the form 1 + 1/(1-p1)*(1-p2)...

    If you then count the occurrence of each probability--it looks like you have a small number of values that recur--you can use the pow() function--pow(1-p, occurences_of_p)*pow(1-q, occurrences_of_q)--and avoid individual roundoff with each multiplication.

提交回复
热议问题