📄 subcluster.h
字号:
/* Scalable K-means clustering softwareCopyright (C) 2000 Fredrik Farnstrom and James LewisThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.See the file README.TXT for more information.*//* subcluster.h */class Singleton;class Subcluster{ float *sum, *sumSquared; float *mean; float *stdDev; long numPoints; float sqrtNumPoints; int dimensions; char modified; Subcluster *next, *previous; Subcluster *clusterAssociation;public: Subcluster(int dim); ~Subcluster(); static long getAllocated(void); void clear(void); // Update the sufficient statistics using point x. void addPoint(Singleton *x); // Update the sufficient statistics with cluster x. void addCluster(Subcluster *x); void subCluster(Subcluster *x); // Measure Mahalanobis distance from x to the mean of the subcluster. float Mahalanobis(float *x); float Mahalanobis(Singleton *p); float Mahalanobis(Subcluster *c); Subcluster *getPrevious(void) { return previous; } Subcluster *getNext(void) { return next; } void setPrevious(Subcluster *p) { previous = p; } void setNext(Subcluster *n) { next = n; } long getMemUsed(void) { return sizeof(*this) + 4*dimensions*sizeof(float); } void associate(Subcluster *cluster) { clusterAssociation = cluster; } Subcluster *getAssociation(void) { return clusterAssociation; } float distanceSquared(Singleton *c); float distanceSquared(Subcluster *c); float updateMean(void); void computeStdDev(void); // Perturb the cluster mean within its confidence intervals, either // towards (if away == 0) or away from point p, and return distance // squared between new cluster mean and p. The cluster is left unchanged. float perturb(Singleton *p, int away, float stdDev); int isTight(float beta); long getNumPoints(void) { return numPoints; } void print(FILE *f = stdin); void printConfidence(FILE *f = stdin);};class MainCluster : public Subcluster{public: MainCluster(int dim) : Subcluster(dim) { }// int numNewPoints; int id;};/* End of file subcluster.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -