编程介的小学生 2017-10-30 08:23 采纳率: 20.5%
浏览 739
已采纳

Practice

Description

How much does winning ACM depend on practice?
We assume that p, the probability that a given team will win a given contest, is related to n, the number of practice problems solved by the team prior to the contest. This relationship is modelled by the logistic formula

log(p/(1-p)) = a + bn ,

for some a and b. Your job is to find a and b such that the formula most accurately reflects a set of observed results.
Each observation consists of n and w. n is the number of practice problems solved by some team prior to a contest, and w is 1 if the team wins the contest, 0 if it does not.

Given a, b, and n the formula above may be used to compute p, the estimated probability that w = 1. The likelihood of a particular observation is p if w = 1 and 1-p if w = 0; The likelihood of a set of observations is the product of the likelihoods of the individual observations.

You are to compute the maximum likelihood estimate for a and b. That is, the values of a and b for which the likelihood of a given set of observations is maximized.

Input

The input contains several test cases followed by a line contatining 0. Each test case begins with 1 < k <= 100, the number of observations that follow. Each observation consists of integers 0 <= n <= 100 and 0 <= w <= 1. The input will contain at least two distinct values of n and of w.
Output

For each test case, output a single line containing a and b, rounded to four digits to the right of the decimal.
Sample Input

20
0 0
0 0
0 0
0 0
1 0
1 0
1 0
1 1
2 0
2 0
2 1
2 1
3 0
3 1
3 1
3 1
4 1
4 1
4 1
4 1
0
Sample Output

-3.1748 1.5874

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-21 15:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?