Fitting a Logistic Curve for Binary Outcomes
Calder Engineering also runs pass/fail tests: a component is loaded to a given level and either survives or does not, recorded as 1 or 0. A straight line through those points is meaningless -- extended a little it predicts survival rates above 1 and below 0 -- so the rig chart fits an S-shaped curve instead. The cover sheet quotes the plain overall pass rate.
Task: Print the fraction of tests that passed.
Input
The first line holds one integer n, the number of tests, where 1 <= n <= 1000. Then come n lines, each holding the load applied and the outcome, separated by a single space. The outcome is 1 for a pass and 0 for a failure, and nothing else.
Output
One line holding the fraction of tests whose outcome was 1 -- the number of passes shared over the number of tests -- rounded to 2 decimal places. A fraction between 0.00 and 1.00, not a count and not a percentage.
Example:
Input:
4
1 0
2 0
3 1
4 1
Output:
0.50
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in