internal virtual void printMatrix(Array2DRowRealMatrix array2DRowRealMatrix) { for (int i = 0; i < array2DRowRealMatrix.getRowDimension(); i++) { for (int j = 0; j < array2DRowRealMatrix.getColumnDimension(); j++) { [email protected](new StringBuilder().append(array2DRowRealMatrix.getEntry(i, j)).append(" ").toString()); } [email protected](); } }
void PrintMatrix(Array2DRowRealMatrix a) { for (int i = 0; i < a.getRowDimension(); i++) { for (int j = 0; j < a.getColumnDimension(); j++) { Console.Write(a.getEntry(i, j) + " "); } Console.WriteLine(); } }
internal virtual double getLikelihoodRatio(double num, int num2, Array2DRowRealMatrix array2DRowRealMatrix) { int num3 = 13; double num4 = 0.5 * ((double)num3 + 0.5 * (double)num3 * (double)(num3 + 1)) * java.lang.Math.log((double)array2DRowRealMatrix.getRowDimension()) * 2.0; int rowDimension = array2DRowRealMatrix.getRowDimension(); int columnDimension = array2DRowRealMatrix.getColumnDimension(); Array2DRowRealMatrix mat = (Array2DRowRealMatrix)array2DRowRealMatrix.getSubMatrix(0, num2 - 1, 0, columnDimension - 1); Array2DRowRealMatrix mat2 = (Array2DRowRealMatrix)array2DRowRealMatrix.getSubMatrix(num2, rowDimension - 1, 0, columnDimension - 1); double num5 = SpeakerIdentification.getBICValue(mat); double num6 = SpeakerIdentification.getBICValue(mat2); return(num - num5 - num6 - num4); }
/** * * @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 */ static double GetLikelihoodRatio(double bicValue, int frame, Array2DRowRealMatrix features) { double bicValue1, bicValue2; int d = Segment.FeaturesSize; 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 static int GetPoint(int start, int length, int step, Array2DRowRealMatrix features) { double max = Double.NegativeInfinity; int ncols = features.getColumnDimension(), point = 0; var sub = (Array2DRowRealMatrix)features.getSubMatrix(start, start + length - 1, 0, ncols - 1); double bicValue = GetBICValue(sub); for (int i = Segment.FeaturesSize + 1; i < length - Segment.FeaturesSize; 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); }
private int getPoint(int num, int num2, int num3, Array2DRowRealMatrix array2DRowRealMatrix) { double num4 = double.NegativeInfinity; int columnDimension = array2DRowRealMatrix.getColumnDimension(); int num5 = 0; Array2DRowRealMatrix array2DRowRealMatrix2 = (Array2DRowRealMatrix)array2DRowRealMatrix.getSubMatrix(num, num + num2 - 1, 0, columnDimension - 1); double num6 = SpeakerIdentification.getBICValue(array2DRowRealMatrix2); for (int i = 14; i < num2 - 13; i += num3) { double num7 = this.getLikelihoodRatio(num6, i, array2DRowRealMatrix2); if (num7 > num4) { num4 = num7; num5 = i; } } if (num4 < (double)0f) { num5 = int.MinValue; } return(num5 + num); }