Changeset 7503
 Timestamp:
 02/21/12 16:28:21 (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionResidualHistogram.cs
r7500 r7503 93 93 if (Content != null) { 94 94 Dictionary<string, List<double>> residuals = CalculateResiduals(); 95 double max = Math.Max(Math.Abs(residuals[ALL_SAMPLES].Min()), Math.Abs(residuals[ALL_SAMPLES].Max()));96 double intervalWidth = (max * 2.0) / bins;97 max = HumanRoundMax(max);95 double realMax = Math.Max(Math.Abs(residuals[ALL_SAMPLES].Min()), Math.Abs(residuals[ALL_SAMPLES].Max())); 96 double roundedMax = HumanRoundMax(realMax); 97 double intervalWidth = (roundedMax * 2.0) / bins; 98 98 intervalWidth = HumanRoundMax(intervalWidth); 99 // sets roundedMax to a value, so that zero will be in the middle of the x axis 100 double help = realMax / intervalWidth; 101 help = help % 1 < 0.5 ? (int)help : (int)help + 1; 102 roundedMax = help * intervalWidth; 99 103 100 104 foreach (string series in ALL_SERIES) { 101 CalculateFrequencies(residuals[series], series, max, intervalWidth);105 CalculateFrequencies(residuals[series], series, roundedMax, intervalWidth); 102 106 if (!series.Equals(ALL_SAMPLES)) 103 107 ShowValues(chart.Series[series], relativeFrequencies[series]); … … 105 109 106 110 ChartArea chartArea = chart.ChartAreas[0]; 107 chartArea.AxisX.Minimum = max  intervalWidth; 108 chartArea.AxisX.Maximum = max + intervalWidth; 109 chartArea.AxisY.Maximum = relativeFrequencies[ALL_SAMPLES].Select(x => x.ElementAt(1)).Max() + 0.02; 110 chartArea.AxisY.Interval = 0.1; 111 chartArea.AxisX.Minimum = roundedMax  intervalWidth; 112 chartArea.AxisX.Maximum = roundedMax + intervalWidth; 113 // get the highest frequency of a residual of any series 114 chartArea.AxisY.Maximum = (from series in relativeFrequencies.Values 115 select (from residual in series 116 select residual.ElementAt(1)).Max()).Max(); 117 if (chartArea.AxisY.Maximum < 0.1) { 118 chartArea.AxisY.Interval = 0.01; 119 chartArea.AxisY.Maximum = Math.Ceiling(chartArea.AxisY.Maximum * 100) / 100; 120 } else { 121 chartArea.AxisY.Interval = 0.1; 122 chartArea.AxisY.Maximum = Math.Ceiling(chartArea.AxisY.Maximum * 10) / 10; 123 } 111 124 chartArea.AxisX.Interval = intervalWidth; 112 int curBins = (int)Math.Round( max/ intervalWidth);125 int curBins = (int)Math.Round((roundedMax * 2) / intervalWidth); 113 126 //shifts the x axis label so that zero is in the middle 114 127 if (curBins % 2 == 0) … … 141 154 142 155 private void CalculateFrequencies(List<double> residualValues, string series, double max, double intervalWidth) { 143 //Series residualSeries = chart.Series[series];144 156 double intervalCenter = intervalWidth / 2.0; 145 157 double sampleCount = residualValues.Count(); … … 151 163 current += intervalWidth; 152 164 } 153 //ShowValues(residualSeries, relativeFrequencies[series]);154 165 } 155 166
Note: See TracChangeset
for help on using the changeset viewer.