Example #1
0
        public void MergeWith(SpeakerCluster target)
        {
            if (target == null)
            {
                throw new NullReferenceException();
            }
            var it = target._segmentSet.GetEnumerator();

            while (it.MoveNext())
            {
                if (!AddSegment(it.Current))
                {
                    Console.WriteLine("Something doesn't work in mergeWith method, Cluster class");
                }
            }
            int rowDim           = FeatureMatrix.getRowDimension() + target.FeatureMatrix.getRowDimension();
            int colDim           = FeatureMatrix.getColumnDimension();
            var combinedFeatures = new Array2DRowRealMatrix(rowDim, colDim);

            combinedFeatures.setSubMatrix(FeatureMatrix.getData(), 0, 0);
            combinedFeatures
            .setSubMatrix(target.FeatureMatrix.getData(), FeatureMatrix.getRowDimension(), 0);
            _bicValue     = SpeakerIdentification.GetBICValue(combinedFeatures);
            FeatureMatrix = new Array2DRowRealMatrix(combinedFeatures.getData());
        }
        internal virtual double computeDistance(SpeakerCluster speakerCluster, SpeakerCluster speakerCluster2)
        {
            int rowDimension    = speakerCluster.getFeatureMatrix().getRowDimension() + speakerCluster2.getFeatureMatrix().getRowDimension();
            int columnDimension = speakerCluster.getFeatureMatrix().getColumnDimension();
            Array2DRowRealMatrix array2DRowRealMatrix = new Array2DRowRealMatrix(rowDimension, columnDimension);

            array2DRowRealMatrix.setSubMatrix(speakerCluster.getFeatureMatrix().getData(), 0, 0);
            array2DRowRealMatrix.setSubMatrix(speakerCluster2.getFeatureMatrix().getData(), speakerCluster.getFeatureMatrix().getRowDimension(), 0);
            double num  = SpeakerIdentification.getBICValue(array2DRowRealMatrix);
            double num2 = 13.0;
            double num3 = 0.5 * (num2 + 0.5 * num2 * (num2 + (double)1f)) * java.lang.Math.log((double)array2DRowRealMatrix.getRowDimension()) * 2.0;

            return(num - speakerCluster.getBicValue() - speakerCluster2.getBicValue() - num3);
        }
        static double ComputeDistance(SpeakerCluster c1, SpeakerCluster c2)
        {
            int rowDim = c1.FeatureMatrix.getRowDimension() + c2.FeatureMatrix.getRowDimension();
            int colDim = c1.FeatureMatrix.getColumnDimension();
            Array2DRowRealMatrix combinedFeatures = new Array2DRowRealMatrix(rowDim, colDim);

            combinedFeatures.setSubMatrix(c1.FeatureMatrix.getData(), 0, 0);
            combinedFeatures.setSubMatrix(c2.FeatureMatrix.getData(), c1.FeatureMatrix.getRowDimension(), 0);
            double bicValue = GetBICValue(combinedFeatures);
            double d        = Segment.FeaturesSize;
            double penalty  = 0.5 * (d + 0.5 * d * (d + 1)) * Math.Log(combinedFeatures.getRowDimension()) * 2;

            return(bicValue - c1.GetBicValue() - c2.GetBicValue() - penalty);
        }
        public virtual void mergeWith(SpeakerCluster target)
        {
            if (target == null)
            {
                throw new NullPointerException();
            }
            Iterator iterator = target.segmentSet.iterator();

            while (iterator.hasNext())
            {
                if (!this.addSegment((Segment)iterator.next()).booleanValue())
                {
                    [email protected]("Something doesn't work in mergeWith method, Cluster class");
                }
            }
            int rowDimension    = this.featureMatrix.getRowDimension() + target.getFeatureMatrix().getRowDimension();
            int columnDimension = this.featureMatrix.getColumnDimension();
            Array2DRowRealMatrix array2DRowRealMatrix = new Array2DRowRealMatrix(rowDimension, columnDimension);

            array2DRowRealMatrix.setSubMatrix(this.featureMatrix.getData(), 0, 0);
            array2DRowRealMatrix.setSubMatrix(target.getFeatureMatrix().getData(), this.featureMatrix.getRowDimension(), 0);
            this.bicValue      = SpeakerIdentification.getBICValue(array2DRowRealMatrix);
            this.featureMatrix = new Array2DRowRealMatrix(array2DRowRealMatrix.getData());
        }