|
13 | 13 | import org.mwg.ml.ProgressReporter; |
14 | 14 | import org.mwg.ml.algorithm.profiling.GaussianMixtureNode; |
15 | 15 | import org.mwg.ml.algorithm.profiling.ProbaDistribution; |
| 16 | +import org.mwg.ml.algorithm.profiling.ProbaDistribution2; |
| 17 | +import org.mwg.ml.common.NDimentionalArray; |
16 | 18 | import org.mwg.ml.common.matrix.Matrix; |
17 | 19 | import org.mwg.ml.common.matrix.operation.MultivariateNormalDistribution; |
18 | 20 |
|
@@ -53,9 +55,11 @@ public class Graph3D extends JFrame implements PropertyChangeListener { |
53 | 55 | private JLabel processinginfo; |
54 | 56 | private JTextField textX; |
55 | 57 | private JTextField textY; |
| 58 | + private JCheckBox fastCalc; |
56 | 59 | private double[] err; |
57 | 60 | private int[] xConfig = {0, 24, 48}; |
58 | 61 | private int[] yConfig = {0, 1000, 100}; |
| 62 | + private double[] range; |
59 | 63 | private boolean automaticMax = false; |
60 | 64 | private boolean displayGraph = false; |
61 | 65 |
|
@@ -147,19 +151,18 @@ private Plot3DPanel generatePlot() { |
147 | 151 | } |
148 | 152 | } |
149 | 153 |
|
150 | | - double yrange; |
151 | | - yrange = (yConfig[1] - yConfig[0]); |
152 | | - yrange = yrange / yConfig[2]; |
| 154 | + range= new double[2]; |
| 155 | + range[1] = (yConfig[1] - yConfig[0]); |
| 156 | + range[1] = range[1] / yConfig[2]; |
153 | 157 |
|
154 | | - double xrange; |
155 | | - xrange = (xConfig[1] - xConfig[0]); |
156 | | - xrange = xrange / xConfig[2]; |
| 158 | + range[0] = (xConfig[1] - xConfig[0]); |
| 159 | + range[0] = range[0] / xConfig[2]; |
157 | 160 |
|
158 | 161 | for (int i = 0; i < yArray.length; i++) { |
159 | | - yArray[i] = i * yrange + yConfig[0]; |
| 162 | + yArray[i] = i * range[1] + yConfig[0]; |
160 | 163 | } |
161 | 164 | for (int i = 0; i < xArray.length; i++) { |
162 | | - xArray[i] = i * xrange + xConfig[0]; |
| 165 | + xArray[i] = i * range[0] + xConfig[0]; |
163 | 166 | } |
164 | 167 |
|
165 | 168 | double[][] featArray = new double[(xArray.length * yArray.length)][2]; |
@@ -243,7 +246,18 @@ private double[] calculateArray(double[][] features, double[] min, double[] max) |
243 | 246 | CountDownLatch countDownLatch = new CountDownLatch(1); |
244 | 247 | profiler.query(selectedCalcLevel, min, max, probabilities -> { |
245 | 248 | if (probabilities != null) { |
246 | | - res[0] = probabilities.calculateArray(features, this); |
| 249 | + |
| 250 | + if(!fastCalc.isSelected()) { |
| 251 | + res[0] = probabilities.calculateArray(features, this); |
| 252 | + } |
| 253 | + else { |
| 254 | + ProbaDistribution2 newCalc = new ProbaDistribution2(probabilities.total, probabilities.distributions, probabilities.global); |
| 255 | + NDimentionalArray temp = newCalc.calculate(min, max, range, err, null); |
| 256 | + res[0]=new double[features.length]; |
| 257 | + for(int i=0;i<features.length;i++){ |
| 258 | + res[0][i]=temp.get(features[i]); |
| 259 | + } |
| 260 | + } |
247 | 261 | updateProgress(100); |
248 | 262 | countDownLatch.countDown(); |
249 | 263 | } |
@@ -369,7 +383,7 @@ private void initUI() { |
369 | 383 | spUp.setContinuousLayout(true); |
370 | 384 | spUp.setDividerLocation(this.getWidth() - 300); |
371 | 385 |
|
372 | | - GridLayout experimentLayout = new GridLayout(8, 1, 0, 0); |
| 386 | + GridLayout experimentLayout = new GridLayout(9, 1, 0, 0); |
373 | 387 | board.setLayout(experimentLayout); |
374 | 388 |
|
375 | 389 | Integer[] items = new Integer[MAXLEVEL + 2]; |
@@ -412,10 +426,20 @@ public void actionPerformed(ActionEvent e) { |
412 | 426 | processinginfo = new JLabel(""); |
413 | 427 | board.add(processinginfo); |
414 | 428 |
|
| 429 | + fastCalc = new JCheckBox("fast calculation"); |
| 430 | + fastCalc.addActionListener(new ActionListener() { |
| 431 | + @Override |
| 432 | + public void actionPerformed(ActionEvent e) { |
| 433 | + feed(0, null); |
| 434 | + } |
| 435 | + }); |
| 436 | + board.add(fastCalc); |
415 | 437 |
|
416 | 438 | getContentPane().add(spUp, BorderLayout.CENTER); |
417 | 439 |
|
418 | 440 |
|
| 441 | + |
| 442 | + |
419 | 443 | setSize(1600, 1000); |
420 | 444 | setLocationRelativeTo(null); |
421 | 445 |
|
@@ -696,8 +720,6 @@ public void actionPerformed(ActionEvent e) { |
696 | 720 | }); |
697 | 721 |
|
698 | 722 | menu.add(menuItem); |
699 | | - |
700 | | - |
701 | 723 | setJMenuBar(menuBar); |
702 | 724 |
|
703 | 725 |
|
|
0 commit comments