We were discussing how to compare two models. For example, the number of data points must be larger than the number of parameters. if we increase the number of parameters, it will result in goodness of fit and better Chi-square. Consequently the model with higher number of parameters does better.This is articulated as a metric called the mean squared error which is chi-squared divided by degrees of freedom. MSE uses them as numerator and denominator so it represents a trade-off between over-parameterized model and a lower chi-square. A model with a fewer parameters but lower chi-square is preferred.
#codingexercise
Find the Entringer number for a given n,k
An Entringer number is the number of permutations where we have a number formed from the permutation of digits 1 to n+1 such that the first digit starts with k+1 and the digits following that initially fall and then alternatively rise and fall. For example. E(4,2) are
32415
32514
31425
31524
int GetCountEntringer(int n, int k)
{
if (n == 0 && k == 0) return 1;
if (k == 0) return 0;
return GetCountEntringer(n, k-1) + GetCountEntringer(n-1, n-k);
}
From Wolfram definition of Entringer
(4,1) (3,2)
(4,0) (3,3) (3,1) (2,1)
0 (3,2)(3,0) (3,0)(2,2)(2,0)(1,1)
0 (3,1)(2,1) 0 0 (2,1)(1,0) 0 (1,0)(0,0)
0 (3,0)(2,2) (2,0)(1,1)0 0 (2,0)(1,1) 0 0 0 1
0 0 (2,1)(1,0)0(1,0)(0,0) 0 0 0 (1,0)(0,0) 0 0 0 1
0 0 (2,0) (1,1) 0 0 0 1 0 0 0 0 1 0 0 0 1
0 0 0 (1,0)(0,0) 0 0 0 1 0 0 0 0 1 0 0 0 1
0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1
#codingexercise
Find the Entringer number for a given n,k
An Entringer number is the number of permutations where we have a number formed from the permutation of digits 1 to n+1 such that the first digit starts with k+1 and the digits following that initially fall and then alternatively rise and fall. For example. E(4,2) are
32415
32514
31425
31524
int GetCountEntringer(int n, int k)
{
if (n == 0 && k == 0) return 1;
if (k == 0) return 0;
return GetCountEntringer(n, k-1) + GetCountEntringer(n-1, n-k);
}
From Wolfram definition of Entringer
(4,1) (3,2)
(4,0) (3,3) (3,1) (2,1)
0 (3,2)(3,0) (3,0)(2,2)(2,0)(1,1)
0 (3,1)(2,1) 0 0 (2,1)(1,0) 0 (1,0)(0,0)
0 (3,0)(2,2) (2,0)(1,1)0 0 (2,0)(1,1) 0 0 0 1
0 0 (2,1)(1,0)0(1,0)(0,0) 0 0 0 (1,0)(0,0) 0 0 0 1
0 0 (2,0) (1,1) 0 0 0 1 0 0 0 0 1 0 0 0 1
0 0 0 (1,0)(0,0) 0 0 0 1 0 0 0 0 1 0 0 0 1
0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1
No comments:
Post a Comment