/** * * @param bicValue * The bicValue of the model represented by only one Gaussian. * This parameter it's useful when this function is called * repeatedly for different frame values and the same features * parameter * @param frame * the frame which is tested for being a change point * @param features * the feature vectors matrix * @return the likelihood ratio */ double getLikelihoodRatio(double bicValue, int frame, Array2DRowRealMatrix features) { double bicValue1, bicValue2; int d = Segment.FEATURES_SIZE; double penalty = 0.5 * (d + 0.5 * d * (d + 1)) * Math.log(features.getRowDimension()) * 2; int nrows = features.getRowDimension(), ncols = features.getColumnDimension(); Array2DRowRealMatrix sub1, sub2; sub1 = (Array2DRowRealMatrix) features.getSubMatrix(0, frame - 1, 0, ncols - 1); sub2 = (Array2DRowRealMatrix) features.getSubMatrix(frame, nrows - 1, 0, ncols - 1); bicValue1 = getBICValue(sub1); bicValue2 = getBICValue(sub2); return (bicValue - bicValue1 - bicValue2 - penalty); }
/** * @param start * The starting frame * @param length * The length of the interval, as numbers of frames * @param features * The matrix build with feature vectors as rows * @return Returns the changing point in the input represented by features * */ private int getPoint(int start, int length, int step, Array2DRowRealMatrix features) { double max = Double.NEGATIVE_INFINITY; int ncols = features.getColumnDimension(), point = 0; Array2DRowRealMatrix sub = (Array2DRowRealMatrix) features.getSubMatrix(start, start + length - 1, 0, ncols - 1); double bicValue = getBICValue(sub); for (int i = Segment.FEATURES_SIZE + 1; i < length - Segment.FEATURES_SIZE; i += step) { double aux = getLikelihoodRatio(bicValue, i, sub); if (aux > max) { max = aux; point = i; } } if (max < 0) point = Integer.MIN_VALUE; return point + start; }
Segment s = new Segment(previous * Segment.FRAME_LENGTH, (curent - previous) Array2DRowRealMatrix featuresSubset = (Array2DRowRealMatrix) featuresMatrix.getSubMatrix( previous, curent - 1, 0, 12); ret.add(new SpeakerCluster(s, featuresSubset, getBICValue(featuresSubset)));
/** * * @param bicValue * The bicValue of the model represented by only one Gaussian. * This parameter it's useful when this function is called * repeatedly for different frame values and the same features * parameter * @param frame * the frame which is tested for being a change point * @param features * the feature vectors matrix * @return the likelihood ratio */ double getLikelihoodRatio(double bicValue, int frame, Array2DRowRealMatrix features) { double bicValue1, bicValue2; int d = Segment.FEATURES_SIZE; double penalty = 0.5 * (d + 0.5 * d * (d + 1)) * Math.log(features.getRowDimension()) * 2; int nrows = features.getRowDimension(), ncols = features.getColumnDimension(); Array2DRowRealMatrix sub1, sub2; sub1 = (Array2DRowRealMatrix) features.getSubMatrix(0, frame - 1, 0, ncols - 1); sub2 = (Array2DRowRealMatrix) features.getSubMatrix(frame, nrows - 1, 0, ncols - 1); bicValue1 = getBICValue(sub1); bicValue2 = getBICValue(sub2); return (bicValue - bicValue1 - bicValue2 - penalty); }
/** * @param start * The starting frame * @param length * The length of the interval, as numbers of frames * @param features * The matrix build with feature vectors as rows * @return Returns the changing point in the input represented by features * */ private int getPoint(int start, int length, int step, Array2DRowRealMatrix features) { double max = Double.NEGATIVE_INFINITY; int ncols = features.getColumnDimension(), point = 0; Array2DRowRealMatrix sub = (Array2DRowRealMatrix) features.getSubMatrix(start, start + length - 1, 0, ncols - 1); double bicValue = getBICValue(sub); for (int i = Segment.FEATURES_SIZE + 1; i < length - Segment.FEATURES_SIZE; i += step) { double aux = getLikelihoodRatio(bicValue, i, sub); if (aux > max) { max = aux; point = i; } } if (max < 0) point = Integer.MIN_VALUE; return point + start; }
Segment s = new Segment(previous * Segment.FRAME_LENGTH, (curent - previous) Array2DRowRealMatrix featuresSubset = (Array2DRowRealMatrix) featuresMatrix.getSubMatrix( previous, curent - 1, 0, 12); ret.add(new SpeakerCluster(s, featuresSubset, getBICValue(featuresSubset)));