⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datapoints.java,v

📁 包含了模式识别中常用的一些分类器设计算法
💻 JAVA,V
📖 第 1 页 / 共 4 页
字号:
@ Comments changed to suit the Java Documentation Style.@text@d1 5a5 3// file: DataPoints.java//a17 2 * class: DataPoints *d74 2a75 7     * method: DecisionRegion     *     * @@param   DecisionRegion reg: decision region object     *     * @@return  none     *     * constructor initializes the samples to be plotted in the signal paneld94 1a94 6     * method: initialize     *     * @@param    none     * @@return   boolean value     *     * method returns true if valid data is present else it returns falsed96 1a156 5     * method: clearAllSets     *     * @@param    none     * @@return   none     *d182 1a182 1     * method: addPointa185 4     * @@return  none     *     * add a point to the data set that is determined by the index (setNum)     *d214 1a214 1     * method: drawGaussiand217 1a217 1     * @@return  noned225 1a225 13     * method: gaussian     *     * @@param    int points: max points in the distribution     * @@param    double meanx: mean (x) of the distribution     * @@param    double meany: mean (y) of the distribution     * @@param    double c11: covariance matrix element c11     * @@param    double c12: covariance matrix element c12     * @@param    double c21: covariance matrix element c21     * @@param    double c22: covariance matrix element c22     * @@param    double xmin: xaxis minimum scale     * @@param    double xmax: xaxis maximum scale     * @@param    double ymin: yaxis minimum scale     * @@param    double ymax: yaxis maximum scaled227 8a234 1     * @@return   nonea235 1     * create a set of point that correspond to a gaussians distributiona312 5     * method: setTwoGaussian     *     * @@param   none     * @@return  none     *d316 1d387 2d391 1a391 5     * @@param   none     * @@return  none     *     * create a set of point that correspond to four gaussians to     * be displayed on the input canvasa505 5     * method: setOverGaussian     *     * @@param none     * @@return     none     *d509 2a579 5     * method: setTwoEllipses     *     * @@param    none     * @@return   none     *d583 1a652 5     * method: setRotatedEllipses     *     * @@param   none     * @@return  none     *d656 1a725 5     * method: setFourEllipses     *     * @@param   none     * @@return  none     *d729 2a843 5     * method: setToroidal     *     * @@param   none     * @@return  none     *d847 2d930 1a930 6    /**  * method: setYinYang  *  * @@param none  * @@return     none  *d934 2d1037 2a1038 1     * method: convertPointd1040 4a1043 2     * @@param   Point, panelWidth, panelHeight     * @@return  MyPointd1045 1a1045 3     *     * Converts an instance of Point to an instance of MyPoint containing the     * cartesian x-y valuesa1065 8     * method: convertPoints     *     * @@param    Vector     * @@param    panelWidth     * @@param    panelHeight     * @@return   Vector     *     *d1069 5d1090 1a1090 1     * method: convertMyPointd1092 4a1095 7     * @@param    MyPoint     * @@param    panelWidth     * @@param    panelHeight     * @@return   Point     *     *     * Converts an instance of MyPoint to an instance of Pointd1118 2a1119 6     * method: convertMyPoints     *     * @@param   Vector     * @@param   panelWidth     * @@param   panelHeight     * @@return  Vectord1121 4a1125 2     * Converts a Vector of MyPoints to a Vector of points that correspond to     * Java coordinates.  d1144 1a1144 8     * method: setDrawGaussValues     *     * @@param  points     * @@param  covaraince 11     * @@param  covaraince 12     * @@param  covaraince 21     * @@param  covaraince 22     * @@return noned1146 5a1150 1     * sets the gaussian valuesd1167 4a1170 4     * @@param  color for data set 1     * @@param  color for data set 2      * @@param  color for data set 3      * @@param  color for data set 4@1.1log@Initial revision@text@d15 7a21 5// class: DataPoints//// class holds the input DataPoints classes that are to be classified as well// as the classification algorithms needed to compute the decision regions//d24 7a30 7  // *********************************************************************  //  // declare global variables and components  //  // *********************************************************************d32 24a55 24   // declare vectors needed to store the set points  //  int set_index_d = 1;  int type_d = DTYPE_USER_SELECTED;  int selectFlag = 0;  int selStartX = 0;  int selStartY = 0;  int selEndX = 0;  int selEndY = 0;  // the set with double value  //  Vector dset1;  Vector dset2;  Vector dset3;  Vector dset4;  // colors for each set  //  Color color_dset1 = Color.red;    Color color_dset2 = Color.green;  Color color_dset3 = Color.blue;  Color color_dset4 = Color.orange;d57 2a58 2  // gaussian setup  //  d65 2a66 2  //Scale values  //d68 4a71 4    //double xmin = -10.0;    //double xmax = 10.0;    //double ymin = -10.0;    //double ymax = 10.0;  d73 11a83 58  // method: DecisionRegion  //  // arguments:  //    DecisionRegion reg: decision region object  //  // returns  : none  //  // constructor initializes the samples to be plotted in the signal panel  //  DataPoints()  {    // initialize the data set     //    initialize();  }  // *********************************************************************  //  // declare class methods  //  // *********************************************************************  // method: initialize  //  // arguments: none  // return   : boolean value  //  // method returns true if valid data is present else it returns false  //  public boolean initialize()  {    // initialize the data set     //    dset1 = new Vector(40, 20);    dset2 = new Vector(40, 20);    dset3 = new Vector(40, 20);    dset4 = new Vector(40, 20);    return true;  }  // method: isDataValid  //  // arguments: none  // return   : boolean value  //  // method returns true if valid data is present else it returns false  //  public boolean isDataValid()  {    // check if valid data is present in the first data set    //    if (dset1.size() > 0)d85 5a89 1      return true;d91 2a92 2    // check if valid data is present in the second data setd94 1a94 6    if (dset2.size() > 0)    {      return true;    }    // check if valid data is present in the third data setd96 12a107 1    if (dset3.size() > 0)d109 9a117 1      return true;d119 11a129 4    // check if valid data is present in the fourth data set    //    if (dset4.size() > 0)a130 2      return true;    }d132 13a144 4    // indicate that no valid data is present    //    return false;  }d146 17a162 13  // method: clearAllSets  //  // arguments: none  // return   : none  //  // clear out all point form the data sets  //  public void clearAllSets()  {    if (dset1.size() > 0)    {      dset1.removeAllElements();d164 11a174 1    if (dset2.size() > 0)d176 2a177 115      dset2.removeAllElements();    }    if (dset3.size() > 0)    {      dset3.removeAllElements();    }    if (dset4.size() > 0)    {      dset4.removeAllElements();    }  }  // method: addPoint  //  // arguments:   //    Point p: point to be added to the input data class  //  // return   : none  //  // add a point to the data set that is determined by the index (setNum)  //  public void addPoint(MyPoint p)  {    selectFlag = 0;    switch (set_index_d)    {      case 1 :        dset1.addElement(p);        break;      case 2 :        dset2.addElement(p);        break;      case 3 :        dset3.addElement(p);        break;      case 4 :        dset4.addElement(p);        break;    }  }  public void drawGaussian(double meanx, double meany, DisplayScale scale )  {      setGaussian(points, meanx, meany, cov11, cov12, cov21, cov22, scale);  }  // method: gaussian  //  // arguments:  //    int points: max points in the distribution  //    double meanx: mean (x) of the distribution  //    double meany: mean (y) of the distribution  //    double c11: covariance matrix element c11  //    double c12: covariance matrix element c12  //    double c21: covariance matrix element c21  //    double c22: covariance matrix element c22  //    double xmin: xaxis minimum scale  //    double xmax: xaxis maximum scale  //    double ymin: yaxis minimum scale  //    double ymax: yaxis maximum scale  //  // return   : none  //  // create a set of point that correspond to a gaussians distribution  //  public void setGaussian(int points,			  double meanx,			  double meany,			  double c11,			  double c12,			  double c21,			  double c22,			  DisplayScale scale)  {    // declare local variables    //    double xmax, xmin, ymax, ymin;      double[] xval = null;    double[] yval = null;    BiNormal bn = new BiNormal();    // initialize variables    //    xmax = scale.xmax;    xmin = scale.xmin;    ymax = scale.ymax;    ymin = scale.ymin;    xval = new double[points];    yval = new double[points];    // determine the ratio of pixels per seconds    //    //double xpixsec = input_width_a / (xmax - xmin);    //double ypixsec = input_height_a / (ymax - ymin);    // generate the binormal gaussian random deviates    //    bn.gaussian(points, meanx, meany, xval, yval, c11, c12, c21, c22);    // format the point to be plotted on the screen    //    //Vector dist = new Vector(points);    Vector samp = new Vector(points);    for (int i = 0; i < points; i++)    {    	if (set_index_d == 1)d179 3a181 2	    dset1.addElement(new MyPoint(xval[i], yval[i]));	} else if (set_index_d == 2)d183 3a185 2	    dset2.addElement(new MyPoint(xval[i], yval[i]));	} else if (set_index_d == 3)d187 3a189 2	    dset3.addElement(new MyPoint(xval[i], yval[i]));	} elsed191 1a191 1	    dset4.addElement(new MyPoint(xval[i], yval[i]));a192 1       d194 12a205 60    //for (int i = 0; i < points; i++)    //{    // int xpixel = (int) ((input_width_a / 2) + (xpixsec * xval[i]));    // int ypixel = (int) ((input_width_a / 2) - (ypixsec * yval[i]));    // dist.addElement(new Point(xpixel, ypixel));    // samp.addElement(new MyPoint(xval[i], yval[i]));    //}    // clone the distribution to the appropriate data set  }  // method: setTwoGaussian  //  // arguments: none  // return   : none  //  // create a set of point that correspond to two gaussians to  // be displayed on the input canvas  //  public void setTwoGaussian(DisplayScale scale)  {    // declare local variables    //    double xmax, xmin, ymax, ymin;      int maxsize = 0;    double[] xval = null;    double[] yval = null;    BiNormal bn = new BiNormal();    // initialize variables    //    xmax = scale.xmax;    xmin = scale.xmin;    ymax = scale.ymax;    ymin = scale.ymin;    maxsize = 200    ;    xval = new double[maxsize];    yval = new double[maxsize];    // generate the binormal gaussian random deviates    //     bn.gaussian(      maxsize,      xmin + (xmax-xmin)/4.0,      ymax - (ymax-ymin)/4.0,      xval,      yval,      ((0.1*(xmax-xmin))/4)*(((xmax-xmin))/4),      0.0,      0.0,      ((0.1*(ymax-ymin))/4)*(((ymax-ymin))/4));    // format the point to be plotted on the screen    //    Vector first = new Vector(maxsize);    for (int i = 0; i < maxsize; i++)d207 22a228 1        first.addElement(new MyPoint(xval[i], yval[i]));d230 8a237 18    // generate the binormal gaussian random deviates    //     bn.gaussian(      maxsize,      xmax - (xmax-xmin)/4,      ymin + (ymax-ymin)/4,      xval,      yval,      ((0.1*(xmax-xmin))/4)*(((xmax-xmin))/4),      0.0,      0.0,      ((0.1*(ymax-ymin))/4)*(((ymax-ymin))/4));    // format the point to be plotted on the screen    //    Vector second = new Vector(maxsize);    for (int i = 0; i < maxsize; i++)d239 1a239 1      second.addElement(new MyPoint(xval[i], yval[i]));d241 38d280 8a287 3    dset1 = (Vector)first.clone();    dset2 = (Vector)second.clone();  }d289 45a333 48  // method: setFourGaussian  //  // arguments: none  // return   : none  //  // create a set of point that correspond to four gaussians to  // be displayed on the input canvas  //  public void setFourGaussian(DisplayScale scale)  {    // local variables    //    double xmax, xmin, ymax, ymin;      int maxsize = 0;    double[] xval = null;    double[] yval = null;    BiNormal bn = new BiNormal();    // initialize variables    //    xmax = scale.xmax;    xmin = scale.xmin;    ymax = scale.ymax;    ymin = scale.ymin;    maxsize = 200;    xval = new double[maxsize];    yval = new double[maxsize];    // generate the binormal gaussian random deviates    //    bn.gaussian(      maxsize,      xmax - (xmax-xmin)/4.0,      ymax - (ymax-ymin)/4.0,      xval,      yval,      ((0.1*(xmax-xmin))/4)*(((xmax-xmin))/4),      0.0,      0.0,      ((0.1*(ymax-ymin))/4)*(((ymax-ymin))/4));    // format the point to be plotted on the screen    //    Vector first = new Vector(maxsize);    for (int i = 0; i < maxsize; i++)    {      first.addElement(new MyPoint(xval[i], yval[i]));d336 20a355 12    // generate the binormal gaussian random deviates    //    bn.gaussian(      maxsize,      xmin + (xmax-xmin)/4.0,      ymax - (ymax-ymin)/4.0,      xval,      yval,      ((0.1*(xmax-xmin))/4)*(((xmax-xmin))/4),      0.0,      0.0,      ((0.1*(ymax-ymin))/4)*(((ymax-ymin))/4));d357 31a387 7    // format the point to be plotted on the screen    //    Vector second = new Vector(maxsize);    for (int i = 0; i < maxsize; i++)    {      second.addElement(new MyPoint(xval[i], yval[i]));    }d389 20a408 12    // generate the binormal gaussian random deviates    //    bn.gaussian(      maxsize,      xmin + (xmax-xmin)/4.0,      ymin + (ymax-ymin)/4.0,      xval,      yval,      ((0.1*(xmax-xmin))/4)*(((xmax-xmin))/4),      0.0,      0.0,      ((0.1*(ymax-ymin))/4)*(((ymax-ymin))/4));d410 2a411 6    // format the point to be plotted on the screen    //    Vector third = new Vector(maxsize);    for (int i = 0; i < maxsize; i++)    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -