I have been busy for more than a year. I have been idle for some time. I have already completed my previous work .....
This article mainly calculates a series of data intervals. You can query the starting data, ending data, and number of data in each interval from a pile of data, and set the corresponding precision (decimal places ).
Interval Data Structure
1. The range data mainly includes the start data, end data, and number of data in the current range. The structure is as follows:
public struct IntervalData<TKey, TValue> { private TKey _startValue; private TKey _endValue; private TValue _count; public IntervalData(TKey startValue, TKey endValue, TValue count) { this._startValue = startValue; this._endValue = endValue; this._count = count; } public TKey StartValue { get { return this._startValue; } set { this._startValue = value; } } public TKey EndValue { get { return this._endValue; } set { this._endValue = value; } } public TValue Count { get { return this._count; } set { this._count = value; } } }
Interval data computing algorithm
Note the following:
1. The interval must be greater than or equal to 1, and the precision must be less than or equal to 15 (double Precision maximum ).
2. The interval width needs to be fine-tuned, and the corresponding precision value needs to be increased accordingly.
3. the maximum and minimum values need to be fine-tuned, and corresponding Precision values need to be increased or reduced.
IntervalCount { ; IntervalWidth { ; MaxValue { ; MinValue { ; MAX_DIGIT_SCALE = DataCalculator( (intervalCount <= .IntervalCount = .IntervalCount = IList<IntervalData<, >> Calculate(IList<> values, digits = (values == || values.Count == List<IntervalData<, >> IList<IntervalData<, >> CalculateResult(IEnumerable<> values, dataResult = List<IntervalData<, >> startValue = ( index = ; index < .IntervalCount; index++ count = endValue = Math.Round(startValue + ( currValue (currValue >= startValue &&<++ (index == .IntervalCount - && .MaxValue <.MaxValue = IntervalData<, >= AdjustIntervalWidth( intervalWidth = (.MaxValue - .MinValue) / currentIntervalWidth = (currentIntervalWidth <+= / Math.Pow( (currentIntervalWidth == = .IntervalWidth = AdjustMinAndMaxValue(IEnumerable<> values, minValue = maxValue = currentMinValue = (currentMinValue >-= / Math.Pow( currentMaxValue = (currentMaxValue <=+= / Math.Pow(.MinValue =.MaxValue = CheckDoubleScale( (digits < = (digits >=
Specific Application
The application is simple, for example:
IList<> dataPoints = List<>() { -, , , , , calculator = DataCalculator(<IntervalData<, >> datas = calculator.Calculate(dataPoints, = ( data .Format( result =
Output result:
StartValue:-4 EndValue: 16.71 Count: 4
StartValue: 16.71 EndValue: 37.42 Count: 0
StartValue: 37.42 EndValue: 58.13 Count: 0
StartValue: 58.13 EndValue: 78.84 Count: 1
StartValue: 78.84 EndValue: 99.55 Count: 1
You can bind and display the returned data to related images.