Ejemplo n.º 1
0
 @Override
 public void observe(Model<VectorWritable> x) {
   AbstractCluster cl = (AbstractCluster) x;
   setS0(getS0() + cl.getS0());
   setS1(getS1().plus(cl.getS1()));
   setS2(getS2().plus(cl.getS2()));
 }
Ejemplo n.º 2
0
 protected AbstractCluster(Vector center2, Vector radius2, int id2) {
   setNumObservations(0);
   setTotalObservations(0);
   setCenter(new RandomAccessSparseVector(center2));
   setRadius(new RandomAccessSparseVector(radius2));
   setS0(0);
   setS1(center.like());
   setS2(center.like());
   this.id = id2;
 }
Ejemplo n.º 3
0
 public void observe(ClusterObservations observations) {
   setS0(getS0() + observations.getS0());
   if (getS1() == null) {
     setS1(observations.getS1().clone());
   } else {
     getS1().assign(observations.getS1(), Functions.PLUS);
   }
   if (getS2() == null) {
     setS2(observations.getS2().clone());
   } else {
     getS2().assign(observations.getS2(), Functions.PLUS);
   }
 }
Ejemplo n.º 4
0
 public void observe(Vector x) {
   setS0(getS0() + 1);
   if (getS1() == null) {
     setS1(x.clone());
   } else {
     getS1().assign(x, Functions.PLUS);
   }
   Vector x2 = x.times(x);
   if (getS2() == null) {
     setS2(x2);
   } else {
     getS2().assign(x2, Functions.PLUS);
   }
 }
Ejemplo n.º 5
0
 public void observe(Vector x, double weight) {
   if (weight == 1.0) {
     observe(x);
   } else {
     setS0(getS0() + weight);
     Vector weightedX = x.times(weight);
     if (getS1() == null) {
       setS1(weightedX);
     } else {
       getS1().assign(weightedX, Functions.PLUS);
     }
     Vector x2 = x.times(x).times(weight);
     if (getS2() == null) {
       setS2(x2);
     } else {
       getS2().assign(x2, Functions.PLUS);
     }
   }
 }
Ejemplo n.º 6
0
 @Override
 public void computeParameters() {
   if (getS0() == 0) {
     return;
   }
   setNumObservations((long) getS0());
   setTotalObservations(getTotalObservations() + getNumObservations());
   setCenter(getS1().divide(getS0()));
   // compute the component stds
   if (getS0() > 1) {
     setRadius(
         getS2()
             .times(getS0())
             .minus(getS1().times(getS1()))
             .assign(new SquareRootFunction())
             .divide(getS0()));
   }
   setS0(0);
   setS1(center.like());
   setS2(center.like());
 }