-->
当前位置:首页 > 题库

PROGRAMMING:Realize matrix operation, based on standardized data principal component analysis and output the first principal component coefficient

Luz5年前 (2021-05-10)题库435
A 10 * 2-dimensional matrix M is given
![ QQ screenshot 20210101155953. PNG] (~ / b83cc7ae-7242-44fd-a744-9a7280b1962c. PNG)
The matrix multiplication operation (cross multiplication) of matrix M and matrix transpose is realized to obtain n * n square matrix n; ② The data were standardized by Z-score and then analyzed by principal component analysis (or directly by correlation matrix); ③ The linear equation of principal component (first principal component) with the largest contribution rate of output.
###Input format:
In the first line, enter all variable values (separated by spaces), for example: 10.39 7.91 7.64 6.94 6.38 5.22 9.54 8.57 6.24 10.51 20.81 17.96 19.01 17.48 19.58 18.43 17.52 17.02 13.7 20.04.
In the second line, enter the number of samples and variables (separated by spaces), for example: 10 2.
In the third line, enter the number of principal components, for example: 1.
###Output format:
Output the final judgment result. For example, the coefficients of the first principal component linear equation are -0.21, - 0.16, - 0.13, - 0.2, - 0.19, - 0.44, - 0.41, - 0.43, - 0.39, - 0.38.
###Input example:
```in
10.39 7.91 7.64 6.94 6.38 5.22 9.54 8.57 6.24 10.51 20.81 17.96 19.01 17.48 19.58 18.43 17.52 17.02 13.7 20.04
10 2
one
```
```in
10.39 7.91 7.64 6.94 6.38 5.22 9.54 8.57 6.24 10.51 20.81 17.96 19.01 17.48 19.58 18.43 17.52 17.02 13.7 20.04
10 2
two
```
```in
10.39 7.91 7.64 6.94 6.38 5.22 9.54 8.57 6.24 10.51 20.81 17.96 19.01 17.48 19.58 18.43 17.52 17.02 13.7 20.04
5 4
one
```
###Output example:
```out
The coefficients of the first principal component linear equation are -0.21, - 0.16, - 0.13, - 0.2, - 0.19, - 0.44, - 0.41, - 0.43, - 0.39, - 0.38.
```
```out
The coefficients of the second principal component linear equation are -0.27, - 0.07, - 0.13, - 0.1,0.49, - 0.3, - 0.16, - 0.11, - 0.04,0.73.
```
```out
The coefficients of the first principal component linear equation are -0.26, - 0.24, - 0.45, - 0.6, - 0.56.
```






answer:If there is no answer, please comment