Test of random method, of class Matrix.
()
| 129 | * Test of random method, of class Matrix. |
| 130 | */ |
| 131 | @Test |
| 132 | public void testRandom() |
| 133 | { |
| 134 | System.out.println("random"); |
| 135 | int rows = 100; |
| 136 | int cols = 100; |
| 137 | Random rand = RandomUtil.getRandom(); |
| 138 | |
| 139 | DenseMatrix result = Matrix.random(rows, cols, rand); |
| 140 | OnLineStatistics stats = new OnLineStatistics(); |
| 141 | for (int i = 0; i < result.rows(); i++) |
| 142 | for (int j = 0; j < result.cols(); j++) |
| 143 | stats.add(result.get(i, j)); |
| 144 | //if its all random from [0, 1], the mean should be 0.5 |
| 145 | assertEquals(0.5, stats.getMean(), 0.05); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Test of diag method, of class Matrix. |