Skip to content

Commit

Permalink
Renamed function to match naming rules
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Nov 29, 2017
1 parent 708cdbb commit 44f48df
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions AudioAnalysis/AnalysisPrograms/Sandpit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public static void Dev(Arguments arguments)
// the following lines are call counts per minute over all species.
//double[] v = { 0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,1,0,1,4,4,3,4,2,2,2,2,3,2,2,5,3,4,5,4,4,6,6,5,8,11,10,10,10,11,11,10,11,13,12,11,12,8,8,6,8,6,7,8,9,4,7,7,5,7,8,10,7,11,9,10,8,6,7,7,9,13,8,9,8,9,9,10,7,9,11,8,8,7,8,7,10,8,8,9,7,6,5,6,5,7,9,9,7,6,8,11,10,6,7,6,7,7,8,7,6,9,10,7,9,6,7,8,7,8,8,5,5,5,8,7,9,9,9,7,9,7,8,9,9,9,9,8,7,7,7,6,8,8,6,8,10,8,9,10,9,10,12,8,7,7,5,6,4,6,7,9,9,11,7,9,11,10,9,9,10,10,10,10,8,9,7,11,10,11,5,7,9,6,9,12,9,7,10,7,9,9,7,6,6,7,7,8,10,8,8,4,8,9,11,8,5,4,4,5,7,4,7,7,9,12,9,9,8,7,6,7,8,7,8,5,11,7,6,4,7,7,9,9,8,8,9,9,5,7,7,4,7,7,5,10,6,8,6,9,5,3,5,5,6,6,7,5,8,11,11,7,10,8,11,10,10,7,10,6,8,7,1,4,6,9,9,9,7,3,3,2,4,7,4,6,8,7,5,9,9,6,9,8,8,10,11,7,11,9,7,7,5,8,9,13,10,10,6,7,6,4,6,5,8,2,3,1,4,3,3,6,5,4,5,7,9,4,6,5,7,3,5,4,6,5,3,4,6,4,7,7,6,6,4,5,5,2,3,4,4,8,7,6,5,6,5,5,7,8,8,6,6,6,7,6,4,4,5,6,6,3,3,2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1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 5, 2, 3, 2, 2, 2, 2, 3, 3, 1, 2, 3, 2, 4, 3, 2, 2, 1, 1, 3, 4, 4, 3, 1, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 4, 3, 4, 6, 4, 4, 6, 7, 8, 4, 4, 6, 6, 4, 4, 6, 3, 4, 4, 1, 4, 1, 1, 2, 6, 3, 3, 3, 1, 3, 7, 3, 3, 4, 2, 4, 3, 2, 3, 4, 4, 4, 5, 4, 4, 4, 5, 3, 3, 3, 4, 4, 3, 6, 4, 4, 4, 6, 4, 4, 6, 3, 2, 5, 1, 1, 1, 3, 0, 1, 3, 2, 5, 2, 3, 6, 4, 4, 4, 4, 3, 3, 4, 2, 2, 3, 4, 3, 3, 2, 4, 3, 2, 3, 3, 3, 3, 3, 1, 1, 2, 1, 2, 1, 2, 3, 1, 0, 1, 0, 0, 1, 1, 2, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // NW 13thOct2010
double entropy = DataTools.Entropy_normalised(v);
double entropy = DataTools.EntropyNormalised(v);
} // end if (true)

if (false)
Expand Down Expand Up @@ -698,7 +698,7 @@ public static void Dev(Arguments arguments)
string[] words = lines[i].Split(',');
speciesCounts[i] = int.Parse(words[1]);
}
double Hspecies = DataTools.Entropy_normalised(speciesCounts);
double Hspecies = DataTools.EntropyNormalised(speciesCounts);
Console.WriteLine("Species Entropy = " + Hspecies);

int freqBinCount = 256;
Expand Down Expand Up @@ -772,7 +772,7 @@ public static void Dev(Arguments arguments)
}
}
double[] array = DataTools.Matrix2Array(m);
double entropy = DataTools.Entropy_normalised(array);
double entropy = DataTools.EntropyNormalised(array);
mi[i] = entropy;
}

Expand Down Expand Up @@ -849,7 +849,7 @@ public static void Dev(Arguments arguments)
string[] words = lines[i].Split(',');
speciesCounts[i] = int.Parse(words[1]);
}
double Hspecies = DataTools.Entropy_normalised(speciesCounts);
double Hspecies = DataTools.EntropyNormalised(speciesCounts);
Console.WriteLine("Species Entropy = " + Hspecies);

// set up the input data
Expand Down Expand Up @@ -954,7 +954,7 @@ public static void Dev(Arguments arguments)
// Now have the entire data in one structure.
// Next process inf// in probabilities in data structure
//int[] array = DataTools.Matrix2Array(probSgivenF);
//double entropy = DataTools.Entropy_normalised(array);
//double entropy = DataTools.EntropyNormalised(array);
double MI = DataTools.MutualInformation(probSgivenF);

Console.WriteLine(string.Format("\n\nFeature {0}; Category Count {1}", key, valueCategoryCount));
Expand Down
10 changes: 5 additions & 5 deletions AudioAnalysis/AudioAnalysisTools/AcousticEntropy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static double[] CalculateTemporalEntropySpectrum(double[,] spectrogram)
double[] column = MatrixTools.GetColumn(spectrogram, j);

// ENTROPY of freq bin
tenSp[j] = DataTools.Entropy_normalised(DataTools.SquareValues(column));
tenSp[j] = DataTools.EntropyNormalised(DataTools.SquareValues(column));
}

return tenSp;
Expand All @@ -50,15 +50,15 @@ public static Tuple<double, double, double> CalculateSpectralEntropies(double[,]
// Entropy is a measure of ENERGY dispersal, therefore must square the amplitude.
var tuple = SpectrogramTools.CalculateAvgSpectrumAndVarianceSpectrumFromAmplitudeSpectrogram(amplitudeSpectrogram);
double[] averageSpectrum = DataTools.Subarray(tuple.Item1, lowerBinBound, reducedFreqBinCount); // remove low band
double entropyOfAvSpectrum = DataTools.Entropy_normalised(averageSpectrum); // ENTROPY of spectral averages
double entropyOfAvSpectrum = DataTools.EntropyNormalised(averageSpectrum); // ENTROPY of spectral averages
if (double.IsNaN(entropyOfAvSpectrum))
{
entropyOfAvSpectrum = 1.0;
}

// v: ENTROPY OF VARIANCE SPECTRUM - at this point the spectrogram is a noise reduced amplitude spectrogram
double[] varianceSpectrum = DataTools.Subarray(tuple.Item2, lowerBinBound, reducedFreqBinCount); // remove low band
double entropyOfVarianceSpectrum = DataTools.Entropy_normalised(varianceSpectrum); // ENTROPY of spectral variances
double entropyOfVarianceSpectrum = DataTools.EntropyNormalised(varianceSpectrum); // ENTROPY of spectral variances
if (double.IsNaN(entropyOfVarianceSpectrum))
{
entropyOfVarianceSpectrum = 1.0;
Expand All @@ -79,7 +79,7 @@ public static Tuple<double, double, double> CalculateSpectralEntropies(double[,]
}
}

double entropyOfCoeffOfVarSpectrum = DataTools.Entropy_normalised(coeffOfVarSpectrum); // ENTROPY of Coeff Of Variance spectrum
double entropyOfCoeffOfVarSpectrum = DataTools.EntropyNormalised(coeffOfVarSpectrum); // ENTROPY of Coeff Of Variance spectrum
if (double.IsNaN(entropyOfVarianceSpectrum))
{
entropyOfCoeffOfVarSpectrum = 1.0;
Expand All @@ -100,7 +100,7 @@ public static double CalculateEntropyOfSpectralPeaks(double[,] amplitudeSpectrog
// First extract High band SPECTROGRAM which is now noise reduced
var midBandSpectrogram = MatrixTools.Submatrix(amplitudeSpectrogram, 0, lowerBinBound, amplitudeSpectrogram.GetLength(0) - 1, upperBinBound - 1);
var tupleAmplitudePeaks = SpectrogramTools.HistogramOfSpectralPeaks(midBandSpectrogram);
double entropyOfPeakFreqDistr = DataTools.Entropy_normalised(tupleAmplitudePeaks.Item1);
double entropyOfPeakFreqDistr = DataTools.EntropyNormalised(tupleAmplitudePeaks.Item1);
if (double.IsNaN(entropyOfPeakFreqDistr))
{
entropyOfPeakFreqDistr = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ public static EventStatistics AnalyzeAudioEvent(
stats.TemporalMaxRelative = maxRowId / (double)rowAverages.Length;

// calculate the entropy dispersion/concentration indices
stats.TemporalEnergyDistribution = 1 - DataTools.Entropy_normalised(rowAverages);
stats.SpectralEnergyDistribution = 1 - DataTools.Entropy_normalised(columnAverages);
stats.TemporalEnergyDistribution = 1 - DataTools.EntropyNormalised(rowAverages);
stats.SpectralEnergyDistribution = 1 - DataTools.EntropyNormalised(columnAverages);

// calculate the spectral centroid and the dominant frequency
double binCentroid = CalculateSpectralCentroid(columnAverages);
Expand Down
2 changes: 1 addition & 1 deletion AudioAnalysis/AudioAnalysisTools/Indices/IndexCalculate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static IndexCalculateResult Analysis(
summaryIndices.AvgSnrOfActiveFrames = activity.ActiveAvDb;

// vii. ENTROPY of ENERGY ENVELOPE -- 1-Ht because want measure of concentration of acoustic energy.
double entropy = DataTools.Entropy_normalised(DataTools.SquareValues(signalEnvelope));
double entropy = DataTools.EntropyNormalised(DataTools.SquareValues(signalEnvelope));
summaryIndices.TemporalEntropy = 1 - entropy;

// Note that the spectrogram has had the DC bin removed. i.e. has only 256 columns.
Expand Down
4 changes: 2 additions & 2 deletions AudioAnalysis/AudioAnalysisTools/Indices/RainIndices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static RainStruct Get10SecondIndices(double[] signal, double[,] spectrogr
rainIndices.bgNoise = results3.NoiseMode; //bg noise in dB
rainIndices.snr = results3.Snr; //snr
rainIndices.avSig_dB = 20 * Math.Log10(signal.Average()); //10 times log of amplitude squared
rainIndices.temporalEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(signal)); //ENTROPY of ENERGY ENVELOPE
rainIndices.temporalEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(signal)); //ENTROPY of ENERGY ENVELOPE
rainIndices.spikes = spikeIndex;

// ii: calculate the bin id of boundary between mid and low frequency spectrum
Expand All @@ -163,7 +163,7 @@ public static RainStruct Get10SecondIndices(double[] signal, double[,] spectrogr

// iii: ENTROPY OF AVERAGE SPECTRUM and VARIANCE SPECTRUM - at this point the spectrogram is still an amplitude spectrogram
var tuple = SpectrogramTools.CalculateAvgSpectrumAndVarianceSpectrumFromAmplitudeSpectrogram(midbandSpectrogram);
rainIndices.spectralEntropy = DataTools.Entropy_normalised(tuple.Item1); //ENTROPY of spectral averages
rainIndices.spectralEntropy = DataTools.EntropyNormalised(tuple.Item1); //ENTROPY of spectral averages
if (double.IsNaN(rainIndices.spectralEntropy)) rainIndices.spectralEntropy = 1.0;

// iv: CALCULATE Acoustic Complexity Index on the AMPLITUDE SPECTRUM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ public static Tuple<double, double, PointOfInterest[,]> GetEntropy(EventBasedRep
}
}
}
var FrequencyEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var FrameEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var FrequencyEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var FrameEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));

var formatedFrequencyEntropy = (double)decimal.Round((decimal)FrequencyEnergyEntropy, 3);
var formatedFrameEntropy = (double)decimal.Round((decimal)FrameEnergyEntropy, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ public void FeatureSet5Representation(PointOfInterest[,] pointsOfInterest, int r
}
}
}
var columnEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var columnEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));
if (double.IsNaN(columnEnergyEntropy))
{
this.ColumnEnergyEntropy = 1;
Expand Down Expand Up @@ -697,8 +697,8 @@ public void FeatureSet5Representation(PointOfInterest[,] pointsOfInterest, int r
}
}
}
var columnEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var columnEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));
if (double.IsNaN(columnEnergyEntropy))
{
this.ColumnEnergyEntropy = 1;
Expand Down Expand Up @@ -807,8 +807,8 @@ public void FeatureSet11Representation(PointOfInterest[,] pointsOfInterest, int
}
}
}
var columnEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var columnEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));
if (double.IsNaN(columnEnergyEntropy))
{
this.ColumnEnergyEntropy = 1;
Expand Down Expand Up @@ -1044,8 +1044,8 @@ public void FeatureSet5Representation3(PointOfInterest[,] pointsOfInterest, int
}
}
}
var columnEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var columnEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));
if (double.IsNaN(columnEnergyEntropy))
{
this.ColumnEnergyEntropy = 1;
Expand Down Expand Up @@ -1185,8 +1185,8 @@ public void FeatureSet5Representation4(PointOfInterest[,] pointsOfInterest, int
}
}
}
var columnEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var columnEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));
if (double.IsNaN(columnEnergyEntropy))
{
this.ColumnEnergyEntropy = 1;
Expand Down Expand Up @@ -1364,8 +1364,8 @@ public void FeatureSet9Representation(PointOfInterest[,] pointsOfInterest, int r
}
}
}
var columnEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.Entropy_normalised(DataTools.SquareValues(rowEnergy));
var columnEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(columnEnergy));
var rowEnergyEntropy = DataTools.EntropyNormalised(DataTools.SquareValues(rowEnergy));
if (double.IsNaN(columnEnergyEntropy))
{
this.ColumnEnergyEntropy = 1;
Expand Down
8 changes: 4 additions & 4 deletions AudioAnalysis/TowseyLibrary/DataTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3776,7 +3776,7 @@ public static double Entropy(double[,] matrixDistr)
/// <summary>
/// returns the entropy of a vector of values normalized for vector length
/// </summary>
public static double Entropy_normalised(double[] v)
public static double EntropyNormalised(double[] v)
{
//some safety checks but unlikely to happen
int posCount = v.Count(p => p > 0.0);
Expand All @@ -3795,7 +3795,7 @@ public static double Entropy_normalised(double[] v)
return Entropy(pmf2) / normFactor;
}

public static double Entropy_normalised(int[] v)
public static double EntropyNormalised(int[] v)
{
//some safety checks but unlikely to happen
int posCount = v.Count(p => p > 0.0);
Expand Down Expand Up @@ -3847,14 +3847,14 @@ public static double MutualInformation(int[,] counts)
rowProbs[r] = rowSums[r] / (double)totalSum;
}

//double Hrows = DataTools.Entropy_normalised(rowProbs);
//double Hrows = DataTools.EntropyNormalised(rowProbs);
double[] colProbs = new double[colCount]; //pmf = probability mass funciton
for (int c = 0; c < colCount; c++) // for all time frames
{
colProbs[c] = colSums[c] / (double)totalSum;
}

//double Hcols = DataTools.Entropy_normalised(colProbs);
//double Hcols = DataTools.EntropyNormalised(colProbs);
double[,] matrixProbs = new double[rowCount, colCount];
for (int r = 0; r < rowCount; r++) // for all time frames
{
Expand Down

0 comments on commit 44f48df

Please sign in to comment.