This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public float[] Downsample(float[] array, int Length) | |
{ | |
int insert = 0; | |
float[] window = new float[Length]; | |
float[] window_x = new float[Length]; | |
int bucket_size_less_start_and_end = Length - 2; | |
float bucket_size = (float)(array.Length - 2) / bucket_size_less_start_and_end; | |
int a = 0; | |
int next_a = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<Tuple<double, double>> LargestTriangleThreeBuckets(List<Tuple<double, double>> data, int threshold) | |
{ | |
int dataLength = data.Count; | |
if (threshold >= dataLength || threshold == 0) | |
return data; // Nothing to do | |
List<Tuple<double, double>> sampled = new List<Tuple<double, double>>(threshold); | |
// Bucket size. Leave room for start and end data points | |
double every = (double)(dataLength - 2) / (threshold - 2); |