当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1865:Practice

题目描述
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.

输入解释
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.
输出解释
For each test case, output a single line containing a and b, rounded to four digits to the right of the decimal.
输入样例
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
输出样例
-3.1748 1.5874

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1865

最后修改于 2020-10-29T06:16:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 30000