Three-point Error Curves

Source: Internet
Author: User

-Error CurvesTime limit:2000MS Memory Limit:65536KB 64bit IO Format:%i64d &%i64 U SubmitStatus

Description

Josephina is a clever girl and addicted to machine learning recently. She
Pays much attention to a method called Linear discriminant analysis, which
has many interesting properties.
In order to test the algorithm ' s efficiency, she collects many datasets.
What's more, each data was divided into the parts:training data and test
Data. She gets the parameters of the model on training data and test the
Model on test data. To hers surprise, she finds each dataset ' s test error curve is just a parabolic curve. A parabolic curve corresponds to a quadratic function. In mathematics, a quadratic function is a polynomial function of the form f (x) = ax2 + bx + C. The quadratic would degrade to linear function if a = 0.



It's very easy to calculate the minimal error if there are only one Test error curve. However, there is several datasets, which means Josephina would obtain many parabolic curves. Josephina wants to get the tuned parameters, the best performance on all datasets. So she should take the all error curves into account, i.e., she had to deal with many quadric functions and make a new error D Efinition to represent the total error. Now, she focuses on the following new function ' s minimum which related to multiple quadric functions. The new function F (x) is defined as follows:f (x) = Max (Si (x)), i = 1...N. The domain of x is [0, 1000]. Si (x) is a quadric function. Josephina wonders the minimum of F (x). Unfortunately, it ' s too hard for her and solve this problem. As a super programmer, can you help her?

Input

The input contains multiple test cases. The first line is the number of cases T (T < 100). Each case is begins with a number n (n≤10000). Following n lines, each line contains three integers a (0≤a≤100), B (|b|≤5000), C (|c|≤5000), which mean the Corre Sponding coefficients of a quadratic function.

Output

For each test case, the output of the answer in a line. Round to 4 digits after the decimal point.

Sample Input

212 0 022 0 02-4 2 http://blog.csdn.net/pi9nc/article/details/9666627
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 Const Doubleinf=0x3f3f3f3f;7 Const Doubleeps=1e-9;8 9 intN;Ten Doublea[10005],b[10005],c[10005]; One  A DoubleCDoublex) - { -     Doublema=-inf; the      for(intI=1; i<=n;i++) -     { -         Doubley=x*x*a[i]+x*b[i]+C[i]; -         if(y>Ma) +Ma=y; -     } +     returnMa; A } at  - intMain () - { -     intT; -     inti,j,k,l; -scanf"%d",&T); in      while(t--) -     { toscanf"%d",&n); +          for(i=1; i<=n;i++) -         { thescanf"%lf%lf%lf",&a[i],&b[i],&c[i]); *         } $         DoubleLb,ub,mid,mmid,mid_value,mmid_value;Panax Notoginsenglb=0, ub= +; -          while(lb+eps<UB) the         { +Mid= (LB+UB)/2; AMmid= (MID+UB)/2; theMid_value=C (mid); +Mmid_value=C (mmid); -             if(mid_value<=mmid_value) $ub=Mmid; $             Else -lb=mid; -         } theprintf"%.4lf\n", C (UB)); -     }Wuyi     return 0; the}
View Code

Three-point Error Curves

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.