Wilson confidence rating for posts of a user

0

Please login or register to vote for this query.

(click on this box to dismiss)

https://stackapps.com/questions/8555/request-for-user-script-to-calculate-wilson-confidence-ratings-for-posts

Esperanto Language

Q&A for teachers and students of the Esperanto language

;with updown as
(
select p.id,
       p.owneruserid
     , sum(case when v.votetypeid = 2 then 1 else 0 end) upvotes
     , sum(case when v.votetypeid = 3 then 1 else 0 end) downvotes
     , count(*) total
from posts p
inner join votes v on v.postid = p.id
where v.votetypeid in (2,3)
and p.owneruserid = 2157772
group by p.id
       , p.owneruserid
),
zp as (
  select 1.96 z
       , (case when total =0 then null else convert(decimal,upvotes) / total end) p
       , convert(decimal,total) total
       , id
  from updown
)

select id as [Post Link]
     , (p + z * z / (2 * total)
        - z * sqrt((p * (1 - p) + (z * z) / (4 * total)) / total))
        / (1 + (z * z) / total)
from zp
/*
function calculateWilsonRating(upvotes, downvotes) {
    var total = upvotes + downvotes;

    if(total == 0)
        return 0;

    var z = 1.96;  //confidence Z-score for 95% confidence; for 99% confidence use 2.58

    var p = upvotes / total;

    return (p + z * z / (2 * total)
        - z * Math.sqrt((p * (1 - p) + (z * z) / (4 * total)) / total))
        / (1 + (z * z) / total);
}
*/

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results