andycuisong
BAN USERP(at least one offer) = 1 - p(no offer) = 1 - p(no offer for post 1)*p(no offer for post 2)*p(no offer for post 3) by assuming 3 interviews are independent and each person has equal opportunity for each interview.
p = 1 - 2/3*3/4*1/2 = 3/4
Chi-squared test in this example will be an approximation since the sample is not normal distributed so the sum of the (samples)^2 is not chi-squared distributed.
- andycuisong September 25, 2014SELECT name AS winner FROM candidate WHERE ID = (SELECT candidateId FROM vote GROUP BY candidateid ORDER BY COUNT(*) DESC LIMIT 1) AS S
- andycuisong September 19, 2014SELECT S.a1, S.a2 FROM (SELECT a1, rank FROM (SELECT a1, @rank:=@rank+1 AS rank FROM table, (SELECT @rank:=0)r AS R) AS S) JOIN (SELECT a1, rank FROM (SELECT a1, @rank:=@rank+1 AS rank FROM table, (SELECT @rank:=0)r AS U) AS T) ON S.rank = T.rank+1 AND S.a1 = T.a1 AND S.a2=T.a2 UNION SELECT a1, a2 FROM table GROUP BY a1, a2 HAVING COUNT(*)=1
---------------------------------
The idea is first put a rank id number for each row:
rank a1, a2
1, 1, 3
2, 1, 3
3, 2, 4
......
Then self join the table ON table1.rank=table2.rank+1, table1.a1 = table2.a1, table1.a2 = table2.a2. This will just remove 1 duplicate for those (a1, a2) with more than 1 count.
Finally, Union the above results with rows only contain no duplicate pairs (a1, a2)
SELECT user FROM Table GROUP BY user HAVING COUNT(user) = (SELECT COUNT(user) FROM Table GROUP BY user ORDER BY COUNT(user) DESC LIMIT 1)
- andycuisong September 17, 2014
I use mySQL so the syntax is a little bit different. Thanks for pointing out.
- andycuisong October 01, 2014