Error Curves——錯誤曲線

韓小妹發表於2018-10-23

描述

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 is divided into two parts: training data and test
data. She gets the parameters of the model on training data and test the
model on test data. To her 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 will degrade to linear function if a = 0.



It's very easy to calculate the minimal error if there is only one test error curve. However, there are several datasets, which means Josephina will obtain many parabolic curves. Josephina wants to get the tuned parameters that make the best performance on all datasets. So she should take all error curves into account, i.e., she has to deal with many quadric functions and make a new error definition 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 to solve this problem. As a super programmer, can you help her?

輸入

The input contains multiple test cases. The first line is the number of cases T (T < 100). Each case 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 corresponding coefficients of a quadratic function.

輸出

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

樣例輸入

2
1
2 0 0
2
2 0 0
2 -4 2

樣例輸出

0.000
0.500

描述

Josephina是一個聰明的女孩,最近沉迷於機器學習。她對一種叫做線性判別分析的方法進行了大量的研究。有很多有趣的特性。

為了測試演算法的效率,她收集了許多資料集。此外,每個資料被分為兩部分:培訓資料和測試資料。她在訓練資料上得到模型的引數並測試
測試資料模型.令她驚訝的是,她發現每個資料集的測試誤差曲線都只是一個拋物線曲線。拋物線曲線對應於二次函式。在數學中,二次函式是形式F(X)=ax^2+bx+c的多項式函式。二次型將退化為線性函式,如果a=0。

如果只有一條測試誤差曲線,那麼計算最小誤差是非常容易的。然而,有幾個資料集,這意味著Josephina將獲得許多拋物線曲線。Josephina希望得到調整後的引數,使所有資料集的效能最佳。因此,她應該考慮所有的誤差曲線,也就是說,她必須處理許多二次函式,並做一個新的誤差定義來表示總誤差。現在,她將重點放在以下與多個二次函式相關的新函式的最小值上。新函式f(X)定義如下:f(X)=Max(si(X)),i=1….X的域是[0,1000]。si(X)是一個二次函式。Josephina質疑f(X)的最小值。不幸的是,解決這個問題對她來說太難了。作為一個超級程式設計師,你能幫她嗎?

輸入

輸入包含多個測試用例。第一行是t(t<100)的案件數。每個情況都以一個數字N(N≤10000)開始。以下N行,每一行包含三個整數a(0≤a≤100)、B(|B|≤5000)、C(|C|≤5000),表示一個二次函式的對應係數。

輸出

對於每個測試用例,在一行中輸出答案。四捨五入到小數點後3位。

 

相關文章