第八章第二十五题(马尔科夫矩阵)(markov matrix)
-
*8.25(马尔科夫矩阵)一个nxn的矩阵,如果每个元素都是正数,并且每列的元素的和为1,则称为正马尔科夫矩阵。
public static boolean isMarkovMatrix(double[][] m)
编写下面的方法来检测一个矩阵:是否是马尔科夫矩阵编写一个测试程序,提示用户输入一个3×3的Double值的矩阵,测试他是否是马尔可夫矩阵。下面是一个运行示例:
Enter a 3-by-3 matrix row by row:
0.15 0.875 0.375
0.55 0.005 0.225
0.30 0.12 0.4
It is a Markov matrix
*8.25(markov matrix)An NxN matrix is called a positive Markov matrix if each element is positive and the sum of the elements in each column is 1.
public static boolean isMarkovMatrix(double[][] m)
Write the following method to detect a matrix: whether it is a Markov matrix, write a test program, prompt the user to input a 3 × 3 double matrix, and test whether it is a Markov matrix. Here is a running example:
Enter a 3-by-3 matrix row by row:
0.15 0.875 0.375
0.55 0.005 0.225
0.30 0.12 0.4
It is a Markov matrix -
参考代码:
package chapter08; import java.util.Scanner; public class Code_25 { public static void main(String[] args) { Scanner input =new Scanner(System.