Class DataTools
Assembly: TowseyLibrary.dll
Fields
|
Improve this Doc
View Source
Declaration
public const double ln2 = 0.69314718
Field Value
|
Improve this Doc
View Source
assumes date string has following 8 digit strcture YYYYMMDD.
Declaration
public static string[] MonthNames
Field Value
Methods
|
Improve this Doc
View Source
ADD matrix m2 to matrix m1.
Declaration
public static double[, ] AddMatrices(double[, ] m1, double[, ] m2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] AddVectors(double[] v1, double[] v2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double AntiLog(double value, double logBase)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double AntiLogBase10(double value)
Parameters
Type |
Name |
Description |
Double |
value |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double areaUnderCurve(double x1, double y1, double x2, double y2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static byte[, ] Array2Matrix(byte[] array, int width, int height)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static string Array2String(double[] array)
Parameters
Type |
Name |
Description |
Double[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static string Array2String(int[] array)
Parameters
Type |
Name |
Description |
Int32[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static string Array2String(string[] array)
Parameters
Type |
Name |
Description |
String[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] Bool2Binary(bool[] boolArray)
Parameters
Type |
Name |
Description |
Boolean[] |
boolArray |
|
Returns
|
Improve this Doc
View Source
bounds a sequence of numbers between a minimum and a maximum.
Numbers that fall outside the bound are truncated to the bound.
Declaration
public static double[] BoundArray(double[] A, double min, double max)
Parameters
Type |
Name |
Description |
Double[] |
A |
array to be bound.
|
Double |
min |
The minimum bound.
|
Double |
max |
The maximum bound.
|
Returns
|
Improve this Doc
View Source
bounds a matrix of numbers between a minimum and a maximum.
Numbers that fall outside the bound are truncated to the bound.
Declaration
public static double[, ] BoundMatrix(double[, ] M, double min, double max)
Parameters
Type |
Name |
Description |
Double[,] |
M |
the matrix to be bound.
|
Double |
min |
The minimum bound.
|
Double |
max |
The maximum bound.
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] Clip(double[, ] m, double minPercentile, double maxPercentile)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static long combinatorial(int N, int K)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] ConcatenateVectors(List<double[]> list)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] ConcatenateVectors(params double[][] vectors)
Parameters
Type |
Name |
Description |
Double[][] |
vectors |
|
Returns
|
Improve this Doc
View Source
converts an array of arrays to a matrix.
Declaration
public static double[, ] ConvertJaggedToMatrix(double[][] list)
Parameters
Type |
Name |
Description |
Double[][] |
list |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] ConvertList2Matrix(List<double[]> list)
Parameters
Returns
|
Improve this Doc
View Source
calculates the cumulative probabilities from a prob array.
assumes that values in the data vector are >= zero and sum = 1.0.
Declaration
public static double[] ConvertProbabilityDistribution2CummulativeProbabilites(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] ConvertStringArrayToDoubles(string[] list)
Parameters
Type |
Name |
Description |
String[] |
list |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double CosineSimilarity(double[] v1, double[] v2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double CosineSimilarity(double[, ] m1, double[, ] m2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static void CountPeaks(double[] array, out int count, out double sum)
Parameters
|
Improve this Doc
View Source
counts the positive values in an array. Called by Classifier.Scan(Sonogram s).
Declaration
public static int CountPositives(double[] values)
Parameters
Type |
Name |
Description |
Double[] |
values |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CountPositives(int[] values)
Parameters
Type |
Name |
Description |
Int32[] |
values |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int CountTrues(bool[] peaks)
Parameters
Type |
Name |
Description |
Boolean[] |
peaks |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] Data2Bins(int[] data, int min, int binWidth, int numBins)
Parameters
Returns
|
Improve this Doc
View Source
shift values by their mean.
Declaration
public static double[] DiffFromMean(double[] V)
Parameters
Type |
Name |
Description |
Double[] |
V |
|
Returns
|
Improve this Doc
View Source
shift values by their mean.
Declaration
public static double[, ] DiffFromMean(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns
|
Improve this Doc
View Source
This method requires that v1 and v2 have same dimensions.
Declaration
public static double DotProduct(double[] v1, double[] v2)
Parameters
Returns
Type |
Description |
Double |
The dot product.
|
|
Improve this Doc
View Source
Declaration
public static double DotProduct(double[, ] m1, double[, ] m2)
Parameters
Returns
|
Improve this Doc
View Source
Calculates the entropy of the passed discrete distribution.
It is assumed that each of the elements in distr[] represent the
probability of that state and that the probabilities sum to 1.0
Math.log() is base e. To convert to log base 2 need to divide by the natural log of 2 = ln2 = 0.69314.
NOTE: In the limit as rf approaches 0, rf*log(rf) = 0.
Declaration
public static double Entropy(double[] distr)
Parameters
Type |
Name |
Description |
Double[] |
distr |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double Entropy(double[, ] matrixDistr)
Parameters
Type |
Name |
Description |
Double[,] |
matrixDistr |
|
Returns
|
Improve this Doc
View Source
returns the entropy of a vector of values normalized for vector length.
Declaration
public static double EntropyNormalised(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double EntropyNormalised(int[] v)
Parameters
Type |
Name |
Description |
Int32[] |
v |
|
Returns
|
Improve this Doc
View Source
returns EUCLIDEAN DISTANCE BETWEEN two vectors of byte.
Declaration
public static double EuclideanDistance(byte[] v1, byte[] v2)
Parameters
Type |
Name |
Description |
Byte[] |
v1 |
|
Byte[] |
v2 |
|
Returns
|
Improve this Doc
View Source
returns EUCLIDEAN DISTANCE BETWEEN two vectors.
Declaration
public static double EuclideanDistance(double[] v1, double[] v2)
Parameters
Returns
|
Improve this Doc
View Source
returns EUCLIDIAN DISTANCE BETWEEN two matrices.
Declaration
public double EuclideanDistance(double[, ] m1, double[, ] m2)
Parameters
Returns
|
Improve this Doc
View Source
A new and more accurate version of the moving average filter.
The previous version had some errors in calculation of the trailing edge.
This version is also more efficient because it does not have a double loop.
It also makes a distinction between odd and even window width.
Declaration
public static double[] filterMovingAverage(double[] signal, int width)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] filterMovingAverage(int[] signal, int width)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static float[] filterMovingAverage(float[] signal, int width)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] filterMovingAverageEven(double[] signal, int width)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] filterMovingAverageOdd(double[] signal, int width)
Parameters
Returns
|
Improve this Doc
View Source
An old and now deprecated version of the moving averge filter.
Declaration
public static double[] filterMovingAverageOLD(double[] signal, int width)
Parameters
Returns
|
Improve this Doc
View Source
returns a list of gaps between the trues in a boolean array.
Declaration
public static List<int> GapLengths(bool[] binaryArray)
Parameters
Type |
Name |
Description |
Boolean[] |
binaryArray |
|
Returns
|
Improve this Doc
View Source
returns a list of gaps between 1s in a binary array.
Declaration
public static List<int> GapLengths(double[] binaryArray)
Parameters
Type |
Name |
Description |
Double[] |
binaryArray |
|
Returns
|
Improve this Doc
View Source
Declaration
public static Type[] GetArrayTypes(List<string[]> listOfArrays)
Parameters
Returns
|
Improve this Doc
View Source
returns the min and max values in a matrix of byte.
Declaration
public static int[] GetByteDistribution(byte[, ] data)
Parameters
Type |
Name |
Description |
Byte[,] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] GetColumn(double[, ] m, int colID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] GetColumnsAverages(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int GetColumnSum(int[, ] m, int colID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int[] GetColumnSums(byte[, ] m)
Parameters
Type |
Name |
Description |
Byte[,] |
m |
|
Returns
|
Improve this Doc
View Source
Declaration
public static List<int> GetEventLengths(bool[] boolArray)
Parameters
Type |
Name |
Description |
Boolean[] |
boolArray |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] GetHistogramOfDistancesBetweenEveryPairOfPeaks(double[] data, double threshold)
Parameters
Returns
|
Improve this Doc
View Source
returns an array of double initialised with passed value.
Declaration
public static double[] GetInitialisedArray(int length, double iniValue)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int GetMaxIndex(List<int> data)
Parameters
Returns
|
Improve this Doc
View Source
Same as above method but returns index instead of outting it!
returns the index of max value in an array of doubles.
array index starts at zero.
Declaration
public static int GetMaxIndex(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void getMaxIndex(double[] data, out int indexMax)
Parameters
|
Improve this Doc
View Source
Same as above method but returns index instead of outting it!
returns the index of max value in an array of doubles.
array index starts at zero.
If more than one value is equal max, then returns location of first.
Declaration
public static int GetMaxIndex(int[] data)
Parameters
Type |
Name |
Description |
Int32[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void getMaxIndex(int[] data, out int indexMax)
Parameters
|
Improve this Doc
View Source
return median of an array.
Declaration
public static double GetMedian(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
same as above but returns the index of data element having minimum value.
Declaration
public static int GetMinIndex(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
This method is used to calculate the mean and SD of acoustic indices whose distributions are very skewed, e.g. temporal entropy and cover.
It returns the min, max, mode and one-sided standard deviation of an array of doubles.
NOTE: The mode is prevented from being in lowest two bins because we typically do not want the mode to be near the minimum value of the distribution.
This method accomodates the possibility that the distribution of index values is a truncated Gaussian or a skewed Gaussian.
Once the modal position has been determined, it is assumed that the Sd is to be determined from the long-tailed side.
i.e. the modal position is assumed to be the average of the underlying distribution.
Declaration
public static void GetModeAndOneTailedStandardDeviation(double[] values, out int[] histogram, out double min, out double max, out int modalBin, out double mode, out double SD)
Parameters
Type |
Name |
Description |
Double[] |
values |
an array of values.
|
Int32[] |
histogram |
histogram dervied from passed array.
|
Double |
min |
min value.
|
Double |
max |
max value in the array.
|
Int32 |
modalBin |
bin having modal value.
|
Double |
mode |
the value of the mode.
|
Double |
SD |
standard deviation of the distribution.
|
|
Improve this Doc
View Source
Assuming the passed histogram represents a distribution of values (derived from acoustic indices). which a signal is added to Gaussian noise,
This method accomodates the possibility that the distribution of values is a truncated Gaussian or a skewed Gaussian.
Once the modal position has been determined, it is assumed that the Sd is to be determined from the long-tailed side.
i.e. the modal position is assumed to be the average of the underlying distribution.
This method is used to calculate the mean and SD of acoustic indices whose distrubtions are very skewed, e.g. temporal entropy and cover.
Declaration
public static void GetModeAndOneTailedStandardDeviation(int[] histo, out int indexOfMode, out int indexOfOneSD)
Parameters
|
Improve this Doc
View Source
Declaration
public static double GetNthLargestValue(double[] data, int N)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double GetNthSmallestValue(double[] data, int N)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int[] GetOrderedPeakLocations(double[] peakValues, int count)
Parameters
Returns
|
Improve this Doc
View Source
Finds the local maxima in a vector.
Declaration
public static bool[] GetPeaks(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Finds the local peaks in a vector whose value exceeds the passed threshold.
Declaration
public static bool[] GetPeaks(double[] data, double threshold)
Parameters
Returns
|
Improve this Doc
View Source
returns an array showing values at the peaks.
Declaration
public static double[] GetPeakValues(double[] array)
Parameters
Type |
Name |
Description |
Double[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] GetRankedIndicesInAscendingOrder(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] GetRankedIndicesInDecendingOrder(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static byte[] GetRow(byte[, ] m, int rowID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] GetRow(double[, ] m, int rowID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int GetRowSum(byte[, ] m, int rowID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double GetRowSum(double[, ] m, int rowID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int GetRowSum(int[, ] m, int rowID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int[] GetRowSums(byte[, ] m)
Parameters
Type |
Name |
Description |
Byte[,] |
m |
|
Returns
|
Improve this Doc
View Source
Declaration
public static bool[] GetTroughs(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] GetWeightedCombinationOfColumns(List<double[]> arrays, double[] wts)
Parameters
Returns
|
Improve this Doc
View Source
Calculates Hamming distance for two vectors of doubles.
d[i] = 1 if((int)Math.Round(Math.Abs(v1[i] - v2[i])) == 1 ).
Declaration
public static int HammingDistance(double[] v1, double[] v2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static bool IsArrayOfBoolean(string[] array)
Parameters
Type |
Name |
Description |
String[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static bool IsArrayOfDouble(string[] array)
Parameters
Type |
Name |
Description |
String[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static bool IsArrayOfInt(string[] array)
Parameters
Type |
Name |
Description |
String[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static bool IsPowerOfTwo(ulong x)
Parameters
Type |
Name |
Description |
UInt64 |
x |
|
Returns
|
Improve this Doc
View Source
Gets the log10 of an array of values.
Assume that all values are non-zero and positive.
Declaration
public static double[] Log10Values(double[] data, double epsilon)
Parameters
Type |
Name |
Description |
Double[] |
data |
The input data array.
|
Double |
epsilon |
The smallest accepted non-zero value.
|
Returns
|
Improve this Doc
View Source
Logical AND of two vectors vector v2 to v1.
Declaration
public static byte[] LogicalORofTwoVectors(byte[] v1, byte[] v2)
Parameters
Type |
Name |
Description |
Byte[] |
v1 |
|
Byte[] |
v2 |
|
Returns
|
Improve this Doc
View Source
returns MANHATTAN DISTANCE BETWEEN two vectors.
Declaration
public static double ManhattanDistance(double[] v1, double[] v2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static byte[] Matrix2Array(byte[, ] M)
Parameters
Type |
Name |
Description |
Byte[,] |
M |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] Matrix2Array(double[,, ] M)
Parameters
Type |
Name |
Description |
Double[,,] |
M |
|
Returns
|
Improve this Doc
View Source
Converts a matrix to a vector by concatenating columns.
Declaration
public static double[] Matrix2Array(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] Matrix2Array(int[,, ] M)
Parameters
Type |
Name |
Description |
Int32[,,] |
M |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] Matrix2Array(int[, ] m)
Parameters
Type |
Name |
Description |
Int32[,] |
m |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] Matrix2Binary(double[, ] M, double threshold)
Parameters
Returns
|
Improve this Doc
View Source
Rotates a matrix 90 degrees anticlockwise.
Used for Syntactic pattern recognition
Converts Image matrix to Spectrogram data orientation.
Declaration
public static double[, ] MatrixRotate90Anticlockwise(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns
|
Improve this Doc
View Source
Rotates a matrix 90 degrees clockwise.
Used for Syntactic pattern recognition
Converts Image matrix to Spectrogram data orientation.
Declaration
public static char[, ] MatrixRotate90Clockwise(char[, ] m)
Parameters
Type |
Name |
Description |
Char[,] |
m |
|
Returns
|
Improve this Doc
View Source
Rotates a matrix 90 degrees clockwise.
Declaration
public static double[, ] MatrixRotate90Clockwise(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns
|
Improve this Doc
View Source
performs a matrix transform.
Declaration
public static byte[, ] MatrixTranspose(byte[, ] M)
Parameters
Type |
Name |
Description |
Byte[,] |
M |
the matrix to transform.
|
Returns
|
Improve this Doc
View Source
transforms a matrix of char.
Used for Syntatctic pttern recognition.
Declaration
public static char[, ] MatrixTranspose(char[, ] m)
Parameters
Type |
Name |
Description |
Char[,] |
m |
|
Returns
|
Improve this Doc
View Source
performs a matrix transform.
Declaration
public static double[, ] MatrixTranspose(double[, ] M)
Parameters
Type |
Name |
Description |
Double[,] |
M |
the matrix to transform.
|
Returns
|
Improve this Doc
View Source
Declaration
public static void MinMax(byte[] data, out byte min, out byte max)
Parameters
|
Improve this Doc
View Source
returns the min and max values in a matrix of byte.
Declaration
public static void MinMax(byte[, ] data, out byte min, out byte max)
Parameters
|
Improve this Doc
View Source
Declaration
public static void MinMax(double[] data, out double min, out double max)
Parameters
|
Improve this Doc
View Source
Declaration
public static void MinMax(double[] data, out int indexMin, out int indexMax, out double min, out double max)
Parameters
|
Improve this Doc
View Source
returns the min and max values in a matrix of doubles.
Declaration
public static void MinMax(double[, ] data, out double min, out double max)
Parameters
|
Improve this Doc
View Source
Returns the min and max of a set of integer values in the passed array.
Declaration
public static void MinMax(int[] data, out int min, out int max)
Parameters
Type |
Name |
Description |
Int32[] |
data |
array ofintegers.
|
Int32 |
min |
min value to return.
|
Int32 |
max |
max value to return.
|
|
Improve this Doc
View Source
Declaration
public static void MinMaxAv(double[] data, out double min, out double max, out double av)
Parameters
|
Improve this Doc
View Source
This algorithm is derived from the Lamel et al algorithm used in the SNR class.
Only difference is return the true model value whereever it is.
The relevant lines have been commented.
Declaration
public static void ModalValue(double[] array, out double Q, out double oneSD)
Parameters
|
Improve this Doc
View Source
Declaration
public static double MutualInformation(int[, ] counts)
Parameters
Type |
Name |
Description |
Int32[,] |
counts |
|
Returns
|
Improve this Doc
View Source
Normalizes the passed array between 0,1.
Ensures all values are positive.
Minimum array value set = 0.0.
Maximum array value set = 1.0.
Declaration
public static double[] normalise(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
normalises the values in a vector between the passed min and max.
Declaration
public static double[] Normalise(double[] v, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
Normalises a vector in 0, 1 and also returns a threshold value accordingly normalised.
Declaration
public static void Normalise(double[] v, double threshold, out double[] output, out double normalisedThreshold)
Parameters
|
Improve this Doc
View Source
normalised matrix of real values to [0,1].
Declaration
public static double[, ] normalise(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
Returns
|
Improve this Doc
View Source
normalises the values in a matrix between the passed min and max.
Declaration
public static double[, ] Normalise(double[, ] m, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
normalizes the passed array between 0,1.
Ensures all values are positive.
WARNING: Where the min = max (e.g. a uniform distribution),
this method will return an array of NaN.
The calling method needs to check for this.
Declaration
public static double[] normalise(int[] v)
Parameters
Type |
Name |
Description |
Int32[] |
v |
|
Returns
|
Improve this Doc
View Source
normalises the values in a matrix such that the minimum value
is the average of the edge values.
Truncate thos original values that are below the edge average.
This method is used to NormaliseMatrixValues image templates where there should be no power at the edge.
Declaration
public static double[, ] normalise_zeroEdge(double[, ] m, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
normalises an array of doubles to probabilities that sum to one.
assumes that values in the data vector are >= zero.
Declaration
public static double[] Normalise2Probabilites(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] normalise2UnitLength(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] normalise2UnitLength(int[] v)
Parameters
Type |
Name |
Description |
Int32[] |
v |
|
Returns
|
Improve this Doc
View Source
Normalizes an array so that the sum of its values (area under curve) = 1.0
Use to express data as probability function.
WARNING: ONLY USE THIS METHOD IF ARRAY CONTAINS NEGATIVE VALUES
First of all normalises array into [0,1]
WARNING: This method will NOT work where have a uniform distribution of negative values.
Declaration
public static double[] NormaliseArea(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Normalizes an array so that the sum of its values (area under curve) = 1.0
Use to express data as probability function.
WARNING: This method will NOT work where have a uniform distribution of negative values.
Declaration
public static double[] NormaliseArea(int[] array)
Parameters
Type |
Name |
Description |
Int32[] |
array |
|
Returns
|
Improve this Doc
View Source
Normalises the passed vector by keeping the vector's zero
but scaling the max value down to 1.0.
WARNING: This method assumes that all values in the passed array are >= zero.
Declaration
public static double[] NormaliseByScalingMaxValueToOne(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
normalises the values in a vector such that the passed min value = 0
and the passed max value = 1.0
Values LT 0.0 and GT 1.0 are truncated.
Declaration
public static double NormaliseInZeroOne(double value, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
normalises the values in a vector such that the passed min value = 0
and the passed max value = 1.0
Values LT 0.0 and GT 1.0 are truncated.
Declaration
public static double[] NormaliseInZeroOne(double[] v, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] NormaliseInZeroOne(double[, ] m, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] NormaliseReverseInZeroOne(double[, ] m, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public double NormaliseValue(double val, double normMin, double normMax)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] NormaliseValues(int[] val, int normMin, int normMax)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] Order(double[] array, double[] order)
Parameters
Returns
|
Improve this Doc
View Source
padString_post(String, Int32)
Declaration
public static string padString_post(string str, int width)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static string padString_pre(string str, int width)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double PatternSimilarity(double[] pattern, double[] data)
Parameters
Returns
|
Improve this Doc
View Source
returns a list containing integer index of every peak > threshold.
Declaration
public static List<int> PeakLocations(double[] array, double threshold)
Parameters
Returns
|
Improve this Doc
View Source
returns an array showing locaiton of peaks.
Declaration
public static void PeakLocations(double[] array, double threshold, out int count, out double[] locations)
Parameters
|
Improve this Doc
View Source
prunes the start and end of an array to remove low values.
Declaration
public static int[] Peaks_CropLowAmplitude(double[] data, double threshold)
Parameters
Type |
Name |
Description |
Double[] |
data |
an array of double.
|
Double |
threshold |
must be in range [0,1].
|
Returns
|
Improve this Doc
View Source
Returns the location of the first and last peaks.
Declaration
public static int[] Peaks_CropToFirstAndLast(double[] data, double severity)
Parameters
Returns
|
Improve this Doc
View Source
returns the min and max percentile values of the values in passed matrix.
Must have previously calculated the min and max values in the matrix.
Declaration
public static void PercentileCutoffs(double[, ] matrix, double minPercentile, double maxPercentile, out double minCut, out double maxCut)
Parameters
Type |
Name |
Description |
Double[,] |
matrix |
the matrix.
|
Double |
minPercentile |
|
Double |
maxPercentile |
|
Double |
minCut |
power value equivalent to minPercentile.
|
Double |
maxCut |
power value equivalent to maxPercentile.
|
|
Improve this Doc
View Source
Searches an array of values for periodicity.
Calls the method PeriodicityDetection() to obtain a score for every combination of period and phase between the passed min and max bounds.
The score is an estimate of the maximum amplitude for all combinations of period and phase.
More accurately, the score is the difference between the average of the periodic indices and the average of the mid-period indices.
Returns the maximum periodic score and the period at which it was obtained.
Declaration
public static Tuple<double, int, int> Periodicity(double[] values, int minPeriod, int maxPeriod)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static Tuple<double, double, int> Periodicity_MeanAndSD(double[] values)
Parameters
Type |
Name |
Description |
Double[] |
values |
|
Returns
|
Improve this Doc
View Source
returns the amplitude of an oscillation in an array having the given period.
Declaration
public static Tuple<double, int> PeriodicityAndPhaseDetection(double[] values, int period, int phase)
Parameters
Returns
|
Improve this Doc
View Source
Returns for each position in an array a periodicity score.
That score is the maximum obtained for a range of periods over three cycles.
This allowes the periodicity to change over the array and still return the maximum periodicity score.
Declaration
public static double[] PeriodicityDetection(double[] values, int minPeriod, int maxPeriod)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int PowerOf2Exponent(int number)
Parameters
Type |
Name |
Description |
Int32 |
number |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double RelativeEntropy(double[] distr)
Parameters
Type |
Name |
Description |
Double[] |
distr |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double RelativeEntropy(double[] dist, double[] refDist)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static List<double[]> RemoveNullElementsFromList(List<double[]> list)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] reverseArray(double[] V)
Parameters
Type |
Name |
Description |
Double[] |
V |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] reverseArray(int[] V)
Parameters
Type |
Name |
Description |
Int32[] |
V |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double roundDouble(double d, int places)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static int[] SampleArrayRandomlyWithoutReplacementUsingProbabilityDistribution(double[] distribution, int sampleCount, int seed)
Parameters
Returns
|
Improve this Doc
View Source
Lengthens or shortens an array of values with appropriate scaling.
However this method does NOT attempt to interpolate estimated values.
Declaration
public static double[] ScaleArray(double[] v, int newLength)
Parameters
Type |
Name |
Description |
Double[] |
v |
the array or vector of values to be scaled.
|
Int32 |
newLength |
the lehgth of the new scaled array.
|
Returns
Type |
Description |
Double[] |
a scaled array.
|
|
Improve this Doc
View Source
Declaration
public static double[, ] ScaleMatrix(double[, ] matrix, int newRowCount, int newColCount)
Parameters
Returns
|
Improve this Doc
View Source
returns a list of acoustic events defined by start, end and intensity score.
Declaration
public static List<double[]> SegmentArrayOnThreshold(double[] values, double threshold)
Parameters
Returns
Type |
Description |
List<Double[]> |
List of double[] containing three values.
|
|
Improve this Doc
View Source
Declaration
public static void SetColumn(double[, ] m, int colID, double[] array)
Parameters
|
Improve this Doc
View Source
set all values in the passed column to zero.
Declaration
public static void SetColumnZero(byte[, ] m, int colID)
Parameters
|
Improve this Doc
View Source
sorts a list of integers.
returns both the sorted array (Item2) and the array indices in rank order (Item1).
Declaration
public static Tuple<int[], int[]> SortArray(List<int> array)
Parameters
Returns
|
Improve this Doc
View Source
sorts an array of doubles in DESCENDING order i.e. max first.
returns both the sorted array (Item2) and the array indices in rank order (Item1).
Declaration
public static Tuple<int[], double[]> SortArray(double[] array)
Parameters
Type |
Name |
Description |
Double[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static Tuple<int[], int[]> SortArray(int[] a)
Parameters
Type |
Name |
Description |
Int32[] |
a |
|
Returns
|
Improve this Doc
View Source
sorts an array of doubles in ASCENDING order.
Returns both the sorted array (Item2) and the original array indices in sort order (Item1)
this is a totally crude sort algorithm but I could not find a MathsNet sort
that also returned the sorted indices.
Declaration
public static Tuple<int[], double[]> SortArrayInAscendingOrder(double[] array)
Parameters
Type |
Name |
Description |
Double[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] SquareRootOfValues(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] SquareValues(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[] Subarray(double[] A, int start, int length)
Parameters
Type |
Name |
Description |
Double[] |
A |
|
Int32 |
start |
|
Int32 |
length |
the length of the subarray to be returned.
|
Returns
|
Improve this Doc
View Source
Declaration
public static int[] Subarray(int[] A, int start, int length)
Parameters
Returns
|
Improve this Doc
View Source
Returns a subarray of the passed array of any type.
Declaration
public static T[] Subarray<T>(T[] array, int start, int length)
Parameters
Type |
Name |
Description |
T[] |
array |
an array of any type.
|
Int32 |
start |
the first element of the subarray.
|
Int32 |
length |
number of elements in subarray.
|
Returns
Type Parameters
|
Improve this Doc
View Source
Returns the submatrix of passed matrix.
Assume that RowTop < RowBottom, && ColumnLeft < ColumnRight
.
Row, column indices start at 0.
Declaration
public static double[, ] Submatrix(double[, ] M, int r1, int c1, int r2, int c2)
Parameters
Returns
|
Improve this Doc
View Source
Subtract matrix m2 from matrix m1.
Declaration
public static double[, ] SubtractMatrices(double[, ] m1, double[, ] m2)
Parameters
Returns
|
Improve this Doc
View Source
subtracts the mean from each value of an array.
Declaration
public static double[] SubtractMean(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
subtracts the value from each value of an array.
Declaration
public static double[] SubtractValue(double[] v, double value)
Parameters
Returns
|
Improve this Doc
View Source
subtracts the value from each value of an array
If below zero, truncate to zero.
Declaration
public static double[] SubtractValueAndTruncateToZero(double[] v, double value)
Parameters
Returns
|
Improve this Doc
View Source
Subtract vector v2 from vector v1.
Declaration
public static double[] SubtractVectors(double[] v1, double[] v2)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double Sum(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int Sum(int[] data)
Parameters
Type |
Name |
Description |
Int32[] |
data |
|
Returns
|
Improve this Doc
View Source
Declaration
public static int SumColumn(int[, ] m, int colID)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] SumMinusDifference(double[] lowerArray, double[] upperArray)
Parameters
Type |
Name |
Description |
Double[] |
lowerArray |
|
Double[] |
upperArray |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void TEST_FilterMovingAverage()
|
Improve this Doc
View Source
Returns binary matrix with values set = 1 if they exceed the threshold else set = 0.
Declaration
public static double[, ] Threshold(double[, ] matrix, double threshold)
Parameters
Returns
|
Improve this Doc
View Source
Assume string has format YYYYMMDD_hhmmss*.
Declaration
public static DateTime Time_ConvertDateString2DateTime(string dateString)
Parameters
Type |
Name |
Description |
String |
dateString |
|
Returns
|
Improve this Doc
View Source
Declaration
public static string Time_ConvertSecs2Mins(double seconds)
Parameters
Type |
Name |
Description |
Double |
seconds |
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] TwoOfThree(double[, ] m1, double[, ] m2, double[, ] m3)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static Type TypeOfArray(string[] array)
Parameters
Type |
Name |
Description |
String[] |
array |
|
Returns
|
Improve this Doc
View Source
Declaration
public static bool ValueInList(int value, int[] data)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[] Vector_NormLength(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
returns the vector normalised for min and max values.
Declaration
public static double[] Vector_NormRange(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
shift values by their mean.
Declaration
public static double[] Vector2Zscores(double[] V)
Parameters
Type |
Name |
Description |
Double[] |
V |
|
Returns
|
Improve this Doc
View Source
reduces length of the passed vector by combining consecutive values into an average.
Declaration
public static double[] VectorDoubleLengthByAverageInterpolation(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
the vector.
|
Returns
Type |
Description |
Double[] |
the reduced vector.
|
|
Improve this Doc
View Source
returns the euclidian length of vector.
Declaration
public static double VectorEuclidianLength(double[] v)
Parameters
Type |
Name |
Description |
Double[] |
v |
|
Returns
|
Improve this Doc
View Source
reduces length of the passed vector by combining consecutive values into an average.
Declaration
public static double[] VectorReduceLength(double[] v, int factor)
Parameters
Type |
Name |
Description |
Double[] |
v |
the vector.
|
Int32 |
factor |
reduction factor.
|
Returns
Type |
Description |
Double[] |
the reduced vector.
|
|
Improve this Doc
View Source
Given an array of monotonically increasing or decreasing values and a reference value,
determine whether the ref value lies above or below the index halfway between the passed lower and upper indices.
This method is recursive. It determines the index of the array whose value is closest to the ref value.
Declaration
public static int WhichSideOfCentre(double[] array, double refValue, int lowerIndex, int upperIndex)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static void writeArray(bool[] array)
Parameters
Type |
Name |
Description |
Boolean[] |
array |
|
|
Improve this Doc
View Source
Declaration
public static void WriteArray(double[] array)
Parameters
Type |
Name |
Description |
Double[] |
array |
|
|
Improve this Doc
View Source
Declaration
public static void writeArray(double[] array, string format)
Parameters
|
Improve this Doc
View Source
Declaration
public static void writeArray(int[] array)
Parameters
Type |
Name |
Description |
Int32[] |
array |
|
|
Improve this Doc
View Source
Declaration
public static void WriteArray(string[] array)
Parameters
Type |
Name |
Description |
String[] |
array |
|
|
Improve this Doc
View Source
Declaration
public static string WriteArrayAsCsvLine(double[] array, string format)
Parameters
Type |
Name |
Description |
Double[] |
array |
an array of double.
|
String |
format |
format string.
|
Returns
|
Improve this Doc
View Source
Declaration
public static void WriteArrayInLine(double[] array, string format)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteArrayList(List<string> list)
Parameters
|
Improve this Doc
View Source
this method written to display silence/noise profile of wav file. May not fit general use.
Must be shifted and scaled because all values are neg.
Declaration
public static void writeBarGraph(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
|
Improve this Doc
View Source
Declaration
public static void writeBarGraph(int[] data)
Parameters
Type |
Name |
Description |
Int32[] |
data |
|
|
Improve this Doc
View Source
Declaration
public static void writeMatrix(double[, ] matrix)
Parameters
Type |
Name |
Description |
Double[,] |
matrix |
|
|
Improve this Doc
View Source
Declaration
public static void writeMatrix(double[, ] matrix, string format)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMatrix(int[, ] matrix)
Parameters
Type |
Name |
Description |
Int32[,] |
matrix |
|
|
Improve this Doc
View Source
Declaration
public static void writeMatrix2File(double[, ] matrix, string fPath)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMinMaxOfArray(double[] data)
Parameters
Type |
Name |
Description |
Double[] |
data |
|
|
Improve this Doc
View Source
Declaration
public static void WriteMinMaxOfArray(string arrayname, double[] data)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMinMaxOfFeatures(double[, ] m)
Parameters
Type |
Name |
Description |
Double[,] |
m |
|
|
Improve this Doc
View Source
counts the zero crossings in a signal.
Declaration
public static int ZeroCrossings(double[] signal)
Parameters
Type |
Name |
Description |
Double[] |
signal |
|
Returns
|
Improve this Doc
View Source
counts the times signal drops from above to below zero.
Declaration
public static int ZeroDippings(double[] signal)
Parameters
Type |
Name |
Description |
Double[] |
signal |
|
Returns
|
Improve this Doc
View Source
counts the times signal rises from below to above zero.
Declaration
public static int ZeroRisings(double[] signal)
Parameters
Type |
Name |
Description |
Double[] |
signal |
|
Returns
Extension Methods