source: branches/MetisMQI/src/main/java/weka/estimators/ConditionalEstimator.java

Last change on this file was 29, checked in by gnappo, 14 years ago

Taggata versione per la demo e aggiunto branch.

File size: 2.7 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 *    ConditionalEstimator.java
19 *    Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.estimators;
24
25import weka.core.RevisionHandler;
26
27 
28/**
29 * Interface for conditional probability estimators. Example code: <p>
30 *
31 * <code> <pre>
32 *   NNConditionalEstimator newEst = new NNConditionalEstimator();
33 *
34 *   // Create 50 random points and add them
35 *   Random r = new Random(seed);
36 *   for(int i = 0; i < 50; i++) {
37 *     int x = Math.abs(r.nextInt() % 100);
38 *     int y = Math.abs(r.nextInt() % 100);
39 *     System.out.println("# " + x + "  " + y);
40 *     newEst.addValue(x, y, 1);
41 *   }
42 *
43 *   // Pick a random conditional value
44 *   int cond = Math.abs(r.nextInt() % 100);
45 *   System.out.println("## Conditional = " + cond);
46 *
47 *   // Print the probabilities conditional on that value
48 *   Estimator result = newEst.getEstimator(cond);
49 *   for(int i = 0; i <= 100; i+= 5) {
50 *     System.out.println(" " + i + "  " + result.getProbability(i));
51 *   }
52 * </pre> </code>
53 *
54 * @author Len Trigg (trigg@cs.waikato.ac.nz)
55 * @version $Revision: 1.7 $
56 */
57public interface ConditionalEstimator extends RevisionHandler {
58
59  /**
60   * Add a new data value to the current estimator.
61   *
62   * @param data the new data value
63   * @param given the new value that data is conditional upon
64   * @param weight the weight assigned to the data value
65   */
66  void addValue(double data, double given, double weight);
67
68  /**
69   * Get a probability estimator for a value
70   *
71   * @param given the new value that data is conditional upon
72   * @return the estimator for the supplied value given the condition
73   */
74  Estimator getEstimator(double given);
75
76  /**
77   * Get a probability for a value conditional on another value
78   *
79   * @param data the value to estimate the probability of
80   * @param given the new value that data is conditional upon
81   * @return the estimator for the supplied value given the condition
82   */
83  double getProbability(double data, double given);
84
85}
86
87
88
89
90
91
92
93
Note: See TracBrowser for help on using the repository browser.