update
This commit is contained in:
parent
25251cd572
commit
0ce7848833
|
@ -27,15 +27,15 @@ namespace NMLS_Graphisch
|
|||
}
|
||||
|
||||
|
||||
static int NumberOfSamples = 1000;
|
||||
static int NumberOfSamples = 20000;
|
||||
const int tracking = 40;
|
||||
static Stack<double> x = new Stack<double>();
|
||||
static Random rnd = new Random();
|
||||
static int windowSize = 6;
|
||||
static double[,] w = new double[windowSize, NumberOfSamples];
|
||||
static double[] _x = new double[NumberOfSamples];
|
||||
static double[,] w = new double[NumberOfSamples, NumberOfSamples];
|
||||
static double learnrate = 0.2;
|
||||
static double[] pixel_array;
|
||||
static int windowSize = 6;
|
||||
|
||||
/*---------------------------------------------------
|
||||
* GO_btn_click()
|
||||
|
@ -200,8 +200,8 @@ namespace NMLS_Graphisch
|
|||
Array.Copy(_x, _sourceIndex, x_part_Array, 0, _arrayLength);
|
||||
double x_middle = (x_count > 0) ? (x_part_Array.Sum() / _arrayLength) : 0;
|
||||
|
||||
|
||||
double x_pred = 0.0;
|
||||
|
||||
double[] x_array = _x;
|
||||
double x_actual = _x[x_count];
|
||||
|
||||
|
@ -265,9 +265,9 @@ namespace NMLS_Graphisch
|
|||
}
|
||||
|
||||
/* Calculating the avearage of the error and the variance of the error */
|
||||
double mittel = x_error.Where(d => !double.IsNaN(d)).Sum() / x_error.Length;
|
||||
double mittel = x_error.Where(d => !double.IsNaN(d)).Skip(windowSize).Sum() / x_error.Length;
|
||||
double varianz = 0.0;
|
||||
foreach (double x_e in x_error)
|
||||
foreach (double x_e in x_error.Skip(windowSize))
|
||||
{
|
||||
if (!double.IsNaN(x_e))
|
||||
varianz += Math.Pow(x_e - mittel, 2);
|
||||
|
@ -381,9 +381,9 @@ namespace NMLS_Graphisch
|
|||
}
|
||||
|
||||
/* Calculating the avearage of the error and the variance of the error */
|
||||
double mittel = x_error.Where(d => !double.IsNaN(d)).Sum() / x_error.Length;
|
||||
double mittel = x_error.Where(d => !double.IsNaN(d)).Skip(windowSize).Sum() / x_error.Length;
|
||||
double varianz = 0.0;
|
||||
foreach (double x_e in x_error)
|
||||
foreach (double x_e in x_error.Skip(windowSize))
|
||||
{
|
||||
if (!double.IsNaN(x_e))
|
||||
varianz += Math.Pow(x_e - mittel, 2);
|
||||
|
@ -499,9 +499,9 @@ namespace NMLS_Graphisch
|
|||
}
|
||||
|
||||
/* Calculating the avearage of the error and the variance of the error */
|
||||
double mittel = x_error.Where(d => !double.IsNaN(d)).Sum() / x_error.Length;
|
||||
double mittel = x_error.Where(d => !double.IsNaN(d)).Skip(windowSize).Sum() / x_error.Length;
|
||||
double varianz = 0.0;
|
||||
foreach (double x_e in x_error)
|
||||
foreach (double x_e in x_error.Skip(windowSize))
|
||||
{
|
||||
if (!double.IsNaN(x_e))
|
||||
varianz += Math.Pow(x_e - mittel, 2);
|
||||
|
@ -549,9 +549,9 @@ namespace NMLS_Graphisch
|
|||
/* Initializing weights and actual values
|
||||
In case no picture is loaded, actual values are generated
|
||||
Then printing them on a chart */
|
||||
for (int i = 0; i < NumberOfSamples; i++)
|
||||
for (int i = 0; i < NumberOfSamples / 2; i++)
|
||||
{
|
||||
_x[i] += ((255.0 / NumberOfSamples) * i);
|
||||
_x[i] += ((255.0 / NumberOfSamples / 2) * i);
|
||||
for (int k = 0; k < windowSize; k++)
|
||||
{
|
||||
w[k, i] = rnd.NextDouble();
|
||||
|
@ -637,19 +637,6 @@ namespace NMLS_Graphisch
|
|||
}
|
||||
}
|
||||
|
||||
/* If NuberOfSamples is greater then 2147483591 its size is over
|
||||
* the limit of C# possible indexes in an array, so we have to decrease
|
||||
* the size of NumberOfSamples */
|
||||
|
||||
NumberOfSamples = (img.Width * img.Height) / 2;
|
||||
|
||||
if (NumberOfSamples > 2147483591 / 5)
|
||||
NumberOfSamples = 2147483591 / 5;
|
||||
|
||||
/* Add every 10% a number into comboBox_pixel for calculating */
|
||||
for (int i = 1; i < 11; i++)
|
||||
comboBox_pixel.Items.Add((int)(NumberOfSamples * 0.1 * i));
|
||||
|
||||
_x = pixel_array;
|
||||
|
||||
/* Recreating the weights with the new size of NumberOfSamples */
|
||||
|
@ -690,7 +677,8 @@ namespace NMLS_Graphisch
|
|||
{
|
||||
windowSize = Int32.Parse(txtBox_windowSize.Text);
|
||||
}
|
||||
}catch(Exception excep)
|
||||
}
|
||||
catch (Exception excep)
|
||||
{
|
||||
MessageBox.Show("Not a valid window size");
|
||||
txtBox_windowSize.Text = "";
|
||||
|
|
Loading…
Reference in New Issue