Guest User

Untitled

a guest
Jul 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import math
  2.  
  3. def rankByPDF(alpha, beta):
  4. mean = alpha / (alpha + beta)
  5. factor = 1.65 * math.sqrt( (alpha * beta) / ( ( (alpha + beta)**2) * (alpha + beta + 1) ) )
  6. return mean - factor
  7.  
  8. ##
  9. ## Property A: 20 5-Stars and 2 1-Stars
  10. ## Alpha = 1 + (20 * 1) + (2 * 0.2) = 21.4
  11. ## Beta = Alpha - 22 (count of all reviews) = 1.6
  12. ##
  13. print "Property A: " + str( rankByPDF(21.4, 1.6) )
  14.  
  15. ##
  16. ## Property B: 6 5-Stars and 1 3-Stars
  17. ## Alpha = 1 + (6 * 1) + (1 * 0.6) = 7.2
  18. ## Beta = Alpha - 7 (count of all reviews) = 0.8
  19. ##
  20. print "Property B: " + str( rankByPDF(7.2, 0.8) )
  21.  
  22. ## Output
  23. ## Property A: 0.844747303679
  24. ## Property B: 0.735
Add Comment
Please, Sign In to add comment