- Home
- Premium Memberships
- Lottery Results
- Forums
- Predictions
- Lottery Post Videos
- News
- Search Drawings
- Search Lottery Post
- Lottery Systems
- Lottery Charts
- Lottery Wheels
- Worldwide Jackpots
- Quick Picks
- On This Day in History
- Blogs
- Online Games
- Premium Features
- Contact Us
- Whitelist Lottery Post
- Rules
- Lottery Book Store
- Lottery Post Gift Shop
The time is now 1:48 am
You last visited
April 24, 2024, 11:31 pm
All times shown are
Eastern Time (GMT-5:00)
The Wave Matrix - Excel 2007 AddinPrev TopicNext Topic
-
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
Offlinewe'll restart the cycle after the draws today.
if you want us to do Power Ball, we will by request only since we are not playing it anymore.
for everyone though, no PM's.
The One Over None
I Know... -
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineWell, we were going to post the whole thing here, but it's too big to format it here.
So, we will post the final equation.
If you want to see the entire process of finding The Ultimate Wave Predictor, click the link or click on the equation.
d is the depth, l is the level; these are explained on the web page.
The One Over None
I Know... -
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineWe're working on posting some of the source code here.
It will be only the functions that generate the Wave Matrix and the Ultimate Wave Predictor.
There are portions of the code we can not release.
In general, the portions that we do release are the majority of where the work gets done.
You can reform the code to meet your own needs.
The One Over None
I Know... -
Quote: Originally posted by JADELottery on Nov 23, 2012
Well, we were going to post the whole thing here, but it's too big to format it here.
So, we will post the final equation.
If you want to see the entire process of finding The Ultimate Wave Predictor, click the link or click on the equation.
d is the depth, l is the level; these are explained on the web page.
I'm sitting here listening to Merle Haggard sipping some coffee!
-
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineWe'll post the code first.
It's being presented in both C# and VB.
C#
----------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace YourOwnNameSpace
{
public class Functions
{
public static double TheUltimateWavePredictor(double[] array, int level)
{
double sum = 0;
for (int i = 0; i < array.Length; i++) sum += Math.Pow(-1, i) * Combinatorial(array.Length + level - 1, i + level) * array[array.Length - i - 1];
return sum / Combinatorial(array.Length + level - 2, level - 1);
}
public static double[][] TheWaveMatrix(double[] array, int regression_type, int iterations, double degree_precision, int algorithm, double rms_ratio, double amplitude_frequency_ratio, int number_of_waves)
{
int items = array.Length;
double[][] matrix = new double[2][];
matrix[0] = new double[2];
matrix[1] = new double[items];
double[][] wavematrix = new double[3 + number_of_waves][];
for (int i = 0; i < (3 + number_of_waves); i++)
{
wavematrix[i] = new double[items];
}
for (int i = 1; i < (2 + number_of_waves); i++)
{
if (i == 1)
{
matrix = Regression(array, regression_type);
wavematrix[0][0] = matrix[0][0];
wavematrix[0][1] = matrix[0][1];
wavematrix[i] = matrix[1];
}
else
{
matrix = BMAWave(array, iterations, degree_precision, algorithm, rms_ratio, amplitude_frequency_ratio);
wavematrix[0][i] = matrix[0][0];
wavematrix[i] = matrix[1];
}
for (int j = 0; j < items; j++)
{
wavematrix[i + 1][j] = array[j] = array[j] - wavematrix[i][j];
}
}
return wavematrix;
}
public static double[][] Regression(double[] array, int regression_type)
{
double a = 0;
double b = 0;
double x = 0;
double y = 0;
int items = array.Length;
double[][] regression_array = new double[2][];
regression_array[0] = new double[2] { a, b };
regression_array[1] = new double[items];
for (int i = 0; i < items; i++)
{
regression_array[1][i] = 0;
}
double sum_x = 0;
double sum_y = 0;
double sum_xx = 0;
double sum_xy = 0;
for (int i = 0; i < items; i++)
{
if (regression_type == 1) { x = i + 1; y = array[i]; } //Linear
if (regression_type == 2) { x = Math.Log(i + 1); y = array[i]; } //Logarithmic
if (regression_type == 3) { x = i + 1; y = Math.Log(array[i]); } //Exponential
if (regression_type == 4) { x = Math.Log(i + 1); y = Math.Log(array[i]); } //Power
sum_x += x;
sum_y += y;
sum_xx += x * x;
sum_xy += x * y;
}
double avg_x = sum_x / items;
double avg_y = sum_y / items;
double avg_xx = sum_xx / items;
double avg_xy = sum_xy / items;
b = (avg_xy - avg_x * avg_y) / (avg_xx - avg_x * avg_x);
if ((regression_type == 1) || (regression_type == 2)) a = avg_y - (b * avg_x);
if ((regression_type == 3) || (regression_type == 4)) a = Math.Exp(avg_y - (b * avg_x));
for (int i = 0; i < items; i++)
{
if (regression_type == 1) regression_array[1][i] = a + b * (i + 1);
if (regression_type == 2) regression_array[1][i] = a + b * Math.Log(i + 1);
if (regression_type == 3) regression_array[1][i] = a * Math.Exp(b * (i + 1));
if (regression_type == 4) regression_array[1][i] = a * Math.Pow((i + 1), b);
}
regression_array[0][0] = a;
regression_array[0][1] = b;
return regression_array;
}
public static double[][] BMAWave(double[] array, int iterations, double degree_precision, int algorithm, double rms_ratio, double amplitude_frequency_ratio)
{
int items = array.Length;
double amplitude_degree;
double frequency_degree;
double amplitude_degree_precision;
double frequency_degree_precision;
bool optimal_found;
bool optimal;
bool last_optimal_state;
double[][] wave = new double[2][];
wave[0] = new double[2] { 0, 0 };
wave[1] = new double[items];
wave[1] = array;
amplitude_degree = 0;
if ((algorithm == 1) || (algorithm == 2))
{
amplitude_degree_precision = 1;
optimal_found = false;
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio);
last_optimal_state = optimal;
do
{
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio);
if (!optimal && !last_optimal_state)
{ amplitude_degree -= amplitude_degree_precision; }
else if (!optimal && last_optimal_state)
{ amplitude_degree -= amplitude_degree_precision; amplitude_degree_precision *= 0.1; }
else if (optimal && !last_optimal_state)
{ amplitude_degree += amplitude_degree_precision; amplitude_degree_precision *= 0.1; }
else if (optimal && last_optimal_state)
{ amplitude_degree += amplitude_degree_precision; }
if (optimal && (amplitude_degree_precision <= degree_precision)) optimal_found = true;
if (Math.Abs(amplitude_degree) >= 100) optimal_found = true;
last_optimal_state = optimal;
}
while (!optimal_found);
}
frequency_degree = 0;
if ((algorithm == 1) || (algorithm == 3))
{
frequency_degree_precision = 1;
optimal_found = false;
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations));
last_optimal_state = optimal;
do
{
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations));
if (!optimal && !last_optimal_state)
{ frequency_degree -= frequency_degree_precision; }
else if (!optimal && last_optimal_state)
{ frequency_degree -= frequency_degree_precision; frequency_degree_precision *= 0.1; }
else if (optimal && !last_optimal_state)
{ frequency_degree += frequency_degree_precision; frequency_degree_precision *= 0.1; }
else if (optimal && last_optimal_state)
{ frequency_degree += frequency_degree_precision; }
if (optimal && (frequency_degree_precision <= degree_precision)) optimal_found = true;
if (Math.Abs(frequency_degree) >= 100) optimal_found = true;
last_optimal_state = optimal;
}
while (!optimal_found);
}
if (algorithm == 1) wave[0][0] = amplitude_frequency_ratio * amplitude_degree + (1 - amplitude_frequency_ratio) * frequency_degree;
if (algorithm == 2) wave[0][0] = amplitude_degree;
if (algorithm == 3) wave[0][0] = frequency_degree;
wave[1] = BMAIteration(array, wave[0][0], iterations);
wave[0][0] = Math.Round(wave[0][0], (int)Math.Abs(Math.Log10(degree_precision)));
return wave;
}
public static bool WaveAmplitudeOptimal(double[] array, double[] BMA_array, double rms_ratio)
{
bool optimal = false;
int itmes = array.Length;
double array_sqr_sum = 0;
double BMA_array_sqr_sum = 0;
double RMS_array = 0;
double RMS_BMA_array = 0;
for (int i = 0; i < itmes; i++)
{
array_sqr_sum += array[i] * array[i];
BMA_array_sqr_sum += BMA_array[i] * BMA_array[i];
}
RMS_array = Math.Sqrt(array_sqr_sum / (double)itmes);
RMS_BMA_array = Math.Sqrt(BMA_array_sqr_sum / (double)itmes);
if ((RMS_array / RMS_BMA_array) > (1.0 / rms_ratio))
{ optimal = true; }
else
{ optimal = false; }
return optimal;
}
public static bool WaveFrequencyOptimal(double[] array)
{
bool optimal = false;
int items = array.Length;
int[] frequency = new int[items];
int[] diff_frequency = new int[items - 1];
int[] diff_diff_frequency = new int[items - 2];
int[] frequency_set = new int[3] { 0, 0, 0 };
for (int i = 0; i < items; i++)
{
if (array[i] > 0)
{ frequency[i] = 1; }
else
{ frequency[i] = 0; }
}
for (int i = 0; i < items - 1; i++)
{
if ((array[i + 1] - array[i]) > 0)
{ diff_frequency[i] = 1; }
else
{ diff_frequency[i] = 0; }
}
for (int i = 0; i < items - 2; i++)
{
if ((array[i + 2] - 2 * array[i + 1] + array[i]) > 0)
{ diff_diff_frequency[i] = 1; }
else
{ diff_diff_frequency[i] = 0; }
}
for (int i = 0; i < frequency.Length - 1; i++)
{
frequency_set[0] += Math.Abs(frequency[i + 1] - frequency[i]);
}
for (int i = 0; i < diff_frequency.Length - 1; i++)
{
frequency_set[1] += Math.Abs(diff_frequency[i + 1] - diff_frequency[i]);
}
for (int i = 0; i < diff_diff_frequency.Length - 1; i++)
{
frequency_set[2] += Math.Abs(diff_diff_frequency[i + 1] - diff_diff_frequency[i]);
}
Array.Sort(frequency_set);
if ((frequency_set[2] - frequency_set[0]) > 3)
{ optimal = false; }
else
{ optimal = true; }
return optimal;
}
public static double[] BMAIteration(double[] array, double degree, int iterations)
{
double[] iteration_array = array;
for (int i = 0; i < iterations; i++)
{
iteration_array = BidirectionalMeanAverage(iteration_array, degree);
}
return iteration_array;
}
public static double[] BidirectionalMeanAverage(double[] array, double degree)
{
int items = array.Length;
double[] array_up = new double[items];
double[] array_down = new double[items];
double[] array_average = new double[items];
array_up[0] = array[0];
for (int i = 1; i < items; i++)
{
array_up[i] = (array_up[i - 1] + Math.Exp(degree) * array[i]) / (1 + Math.Exp(degree));
}
array_down[items - 1] = array[items - 1];
for (int i = items - 2; i > -1; i--)
{
array_down[i] = (array_down[i + 1] + Math.Exp(degree) * array[i]) / (1 + Math.Exp(degree));
}
for (int i = 0; i < items; i++)
{
array_average[i] = (array_up[i] + array_down[i]) / 2;
}
return array_average;
}
public static double Combinatorial(int n, int r)
{
try
{
return Factorial(n) / (Factorial(r) * Factorial(n - r));
}
catch
{
return 0;
}
}
public static double Factorial(int n)
{
try
{
if (n > 0)
{ return n * Factorial(n - 1); }
else
{ return 1; }
}
catch
{
return 0;
}
}
}
}
----------------------------------------------------------------------------------------------------VB
----------------------------------------------------------------------------------------------------
Imports System
Imports System.Collections.Generic
Namespace YourOwnNameSpace
Public Class Functions
Public Shared Function TheUltimateWavePredictor(array As Double(), level As Integer) As Double
Dim sum As Double = 0
For i As Integer = 0 To array.Length - 1
sum += Math.Pow(-1, i) * Combinatorial(array.Length + level - 1, i + level) * array(array.Length - i - 1)
Next
Return sum / Combinatorial(array.Length + level - 2, level - 1)
End Function
Public Shared Function TheWaveMatrix(ByVal array As Double(), ByVal regression_type As Integer, ByVal iterations As Integer, ByVal degree_precision As Double, ByVal algorithm As Integer, ByVal rms_ratio As Double, ByVal amplitude_frequency_ratio As Double, ByVal number_of_waves As Integer) As Double()()
Dim items As Integer = array.Length
Dim matrix As Double()() = New Double(1)() {}
matrix(0) = New Double(1) {}
matrix(1) = New Double(items - 1) {}
Dim wavematrix As Double()() = New Double(3 + (number_of_waves - 1))() {}
For i As Integer = 0 To (3 + number_of_waves) - 1
wavematrix(i) = New Double(items - 1) {}
Next
For i As Integer = 1 To (2 + number_of_waves) - 1
If i = 1 Then
matrix = Regression(array, regression_type)
wavematrix(0)(0) = matrix(0)(0)
wavematrix(0)(1) = matrix(0)(1)
wavematrix(i) = matrix(1)
Else
matrix = BMAWave(array, iterations, degree_precision, algorithm, rms_ratio, amplitude_frequency_ratio)
wavematrix(0)(i) = matrix(0)(0)
wavematrix(i) = matrix(1)
End If
For j As Integer = 0 To items - 1
wavematrix(i + 1)(j) = InlineAssignHelper(array(j), array(j) - wavematrix(i)(j))
Next
Next
Return wavematrix
End Function
Public Shared Function Regression(array As Double(), regression_type As Integer) As Double()()
Dim a As Double = 0
Dim b As Double = 0
Dim x As Double = 0
Dim y As Double = 0
Dim items As Integer = array.Length
Dim regression_array As Double()() = New Double(1)() {}
regression_array(0) = New Double(1) {a, b}
regression_array(1) = New Double(items - 1) {}
For i As Integer = 0 To items - 1
regression_array(1)(i) = 0
Next
Dim sum_x As Double = 0
Dim sum_y As Double = 0
Dim sum_xx As Double = 0
Dim sum_xy As Double = 0
For i As Integer = 0 To items - 1
If regression_type = 1 Then
x = i + 1
y = array(i)
End If
'Linear
If regression_type = 2 Then
x = Math.Log(i + 1)
y = array(i)
End If
'Logarithmic
If regression_type = 3 Then
x = i + 1
y = Math.Log(array(i))
End If
'Exponential
If regression_type = 4 Then
x = Math.Log(i + 1)
y = Math.Log(array(i))
End If
'Power
sum_x += x
sum_y += y
sum_xx += x * x
sum_xy += x * y
Next
Dim avg_x As Double = sum_x / items
Dim avg_y As Double = sum_y / items
Dim avg_xx As Double = sum_xx / items
Dim avg_xy As Double = sum_xy / items
b = (avg_xy - avg_x * avg_y) / (avg_xx - avg_x * avg_x)
If (regression_type = 1) OrElse (regression_type = 2) Then
a = avg_y - (b * avg_x)
End If
If (regression_type = 3) OrElse (regression_type = 4) Then
a = Math.Exp(avg_y - (b * avg_x))
End If
For i As Integer = 0 To items - 1
If regression_type = 1 Then
regression_array(1)(i) = a + b * (i + 1)
End If
If regression_type = 2 Then
regression_array(1)(i) = a + b * Math.Log(i + 1)
End If
If regression_type = 3 Then
regression_array(1)(i) = a * Math.Exp(b * (i + 1))
End If
If regression_type = 4 Then
regression_array(1)(i) = a * Math.Pow((i + 1), b)
End If
Next
regression_array(0)(0) = a
regression_array(0)(1) = b
Return regression_array
End Function
Public Shared Function BMAWave(array As Double(), iterations As Integer, degree_precision As Double, algorithm As Integer, rms_ratio As Double, amplitude_frequency_ratio As Double) As Double()()
Dim items As Integer = array.Length
Dim amplitude_degree As Double
Dim frequency_degree As Double
Dim amplitude_degree_precision As Double
Dim frequency_degree_precision As Double
Dim optimal_found As Boolean
Dim optimal As Boolean
Dim last_optimal_state As Boolean
Dim wave As Double()() = New Double(1)() {}
wave(0) = New Double(1) {0, 0}
wave(1) = New Double(items - 1) {}
wave(1) = array
amplitude_degree = 0
If (algorithm = 1) OrElse (algorithm = 2) Then
amplitude_degree_precision = 1
optimal_found = False
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio)
last_optimal_state = optimal
Do
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio)
If Not optimal AndAlso Not last_optimal_state Then
amplitude_degree -= amplitude_degree_precision
ElseIf Not optimal AndAlso last_optimal_state Then
amplitude_degree -= amplitude_degree_precision
amplitude_degree_precision *= 0.1
ElseIf optimal AndAlso Not last_optimal_state Then
amplitude_degree += amplitude_degree_precision
amplitude_degree_precision *= 0.1
ElseIf optimal AndAlso last_optimal_state Then
amplitude_degree += amplitude_degree_precision
End If
If optimal AndAlso (amplitude_degree_precision <= degree_precision) Then
optimal_found = True
End If
If Math.Abs(amplitude_degree) >= 100 Then
optimal_found = True
End If
last_optimal_state = optimal
Loop While Not optimal_found
End If
frequency_degree = 0
If (algorithm = 1) OrElse (algorithm = 3) Then
frequency_degree_precision = 1
optimal_found = False
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations))
last_optimal_state = optimal
Do
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations))
If Not optimal AndAlso Not last_optimal_state Then
frequency_degree -= frequency_degree_precision
ElseIf Not optimal AndAlso last_optimal_state Then
frequency_degree -= frequency_degree_precision
frequency_degree_precision *= 0.1
ElseIf optimal AndAlso Not last_optimal_state Then
frequency_degree += frequency_degree_precision
frequency_degree_precision *= 0.1
ElseIf optimal AndAlso last_optimal_state Then
frequency_degree += frequency_degree_precision
End If
If optimal AndAlso (frequency_degree_precision <= degree_precision) Then
optimal_found = True
End If
If Math.Abs(frequency_degree) >= 100 Then
optimal_found = True
End If
last_optimal_state = optimal
Loop While Not optimal_found
End If
If algorithm = 1 Then
wave(0)(0) = amplitude_frequency_ratio * amplitude_degree + (1 - amplitude_frequency_ratio) * frequency_degree
End If
If algorithm = 2 Then
wave(0)(0) = amplitude_degree
End If
If algorithm = 3 Then
wave(0)(0) = frequency_degree
End If
wave(1) = BMAIteration(array, wave(0)(0), iterations)
wave(0)(0) = Math.Round(wave(0)(0), CInt(Math.Truncate(Math.Abs(Math.Log10(degree_precision)))))
Return wave
End Function
Public Shared Function WaveAmplitudeOptimal(array As Double(), BMA_array As Double(), rms_ratio As Double) As Boolean
Dim optimal As Boolean = False
Dim itmes As Integer = array.Length
Dim array_sqr_sum As Double = 0
Dim BMA_array_sqr_sum As Double = 0
Dim RMS_array As Double = 0
Dim RMS_BMA_array As Double = 0
For i As Integer = 0 To itmes - 1
array_sqr_sum += array(i) * array(i)
BMA_array_sqr_sum += BMA_array(i) * BMA_array(i)
Next
RMS_array = Math.Sqrt(array_sqr_sum / CDbl(itmes))
RMS_BMA_array = Math.Sqrt(BMA_array_sqr_sum / CDbl(itmes))
If (RMS_array / RMS_BMA_array) > (1.0 / rms_ratio) Then
optimal = True
Else
optimal = False
End If
Return optimal
End Function
Public Shared Function WaveFrequencyOptimal(array__1 As Double()) As Boolean
Dim optimal As Boolean = False
Dim items As Integer = array__1.Length
Dim frequency As Integer() = New Integer(items - 1) {}
Dim diff_frequency As Integer() = New Integer(items - 2) {}
Dim diff_diff_frequency As Integer() = New Integer(items - 3) {}
Dim frequency_set As Integer() = New Integer(2) {0, 0, 0}
For i As Integer = 0 To items - 1
If array__1(i) > 0 Then
frequency(i) = 1
Else
frequency(i) = 0
End If
Next
For i As Integer = 0 To items - 2
If (array__1(i + 1) - array__1(i)) > 0 Then
diff_frequency(i) = 1
Else
diff_frequency(i) = 0
End If
Next
For i As Integer = 0 To items - 3
If (array__1(i + 2) - 2 * array__1(i + 1) + array__1(i)) > 0 Then
diff_diff_frequency(i) = 1
Else
diff_diff_frequency(i) = 0
End If
Next
For i As Integer = 0 To frequency.Length - 2
frequency_set(0) += Math.Abs(frequency(i + 1) - frequency(i))
Next
For i As Integer = 0 To diff_frequency.Length - 2
frequency_set(1) += Math.Abs(diff_frequency(i + 1) - diff_frequency(i))
Next
For i As Integer = 0 To diff_diff_frequency.Length - 2
frequency_set(2) += Math.Abs(diff_diff_frequency(i + 1) - diff_diff_frequency(i))
Next
Array.Sort(frequency_set)
If (frequency_set(2) - frequency_set(0)) > 3 Then
optimal = False
Else
optimal = True
End If
Return optimal
End Function
Public Shared Function BMAIteration(array As Double(), degree As Double, iterations As Integer) As Double()
Dim iteration_array As Double() = array
For i As Integer = 0 To iterations - 1
iteration_array = BidirectionalMeanAverage(iteration_array, degree)
Next
Return iteration_array
End Function
Public Shared Function BidirectionalMeanAverage(array As Double(), degree As Double) As Double()
Dim items As Integer = array.Length
Dim array_up As Double() = New Double(items - 1) {}
Dim array_down As Double() = New Double(items - 1) {}
Dim array_average As Double() = New Double(items - 1) {}
array_up(0) = array(0)
For i As Integer = 1 To items - 1
array_up(i) = (array_up(i - 1) + Math.Exp(degree) * array(i)) / (1 + Math.Exp(degree))
Next
array_down(items - 1) = array(items - 1)
For i As Integer = items - 2 To -1 + 1 Step -1
array_down(i) = (array_down(i + 1) + Math.Exp(degree) * array(i)) / (1 + Math.Exp(degree))
Next
For i As Integer = 0 To items - 1
array_average(i) = (array_up(i) + array_down(i)) / 2
Next
Return array_average
End Function
Public Shared Function Combinatorial(n As Integer, r As Integer) As Double
Try
Return Factorial(n) / (Factorial(r) * Factorial(n - r))
Catch
Return 0
End Try
End Function
Public Shared Function Factorial(n As Integer) As Double
Try
If n > 0 Then
Return n * Factorial(n - 1)
Else
Return 1
End If
Catch
Return 0
End Try
End Function
End Class
End Namespace
----------------------------------------------------------------------------------------------------The One Over None
I Know... -
I will study that. Thanks!
-
Hi JADELottery,
Could the Ultimate Wave Predictor be adapted to any type of lottery or prediction? The formula looks complicated, nice work!
RegardsConsciousness order chaos.
-
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineQuote: Originally posted by Hyperdimension on Nov 23, 2012
Hi JADELottery,
Could the Ultimate Wave Predictor be adapted to any type of lottery or prediction? The formula looks complicated, nice work!
Regardsit's generalized enough to work on any kind of sample set.
although we may have said it works best on oscillating data, it's not restricted to oscillating data.
keep in mind what kind of data you are analyzing.
if you are working with pick 3 numbers, obviously you are working with 0 to 9, or the whole number 0 to 999, then you need to understand how those limits apply to the projection value generated by the Ultimate Wave Predictor.
you can negative values and values greater than 9 or 999.
we have given some examples of what you could do to the projection value in earlier posts.
there may be other limits on other sample or data sets, like sums, root sums.
we find that an integer-modulus or modulus works well in keeping limits on the projection values.The One Over None
I Know... -
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineThe two function to work with are:
TheUltimateWavePredictor
TheWaveMatrix
The other functions are mostly supporting functions.
We will show some examples of how to pass in arrays and data; what to expect back and how to access the information in those functions that return a matrix array.
TheUltimateWavePredictor function takes an array and one integer value, the level of projection averaging, and returns only one value, the possible projected yn+1 value.
Here's an example C# code:
private void some_sub_0()
{
Random random = new Random();
int n_items = 100;
double[] sample_array = new double[n_items];
for (int a = 0; a < n_items; a++)
{
sample_array[a] = 100.0f * random.NextDouble();
}
int depth = 25;
double[] sub_sample_array = new double[depth];
for (int b = 0; b < depth; b++)
{
sub_sample_array[b] = sample_array[n_items - depth + b];
}
int level = 32;
double predicted_value = Functions.TheUltimateWavePredictor(sub_sample_array, level);
}
TheWaveMatrix function takes an array and several different parameters to return the wave matrix.
The parameters are as follows:
double[] array - the data array to be analyzed. It should contain at least (number_of_waves + 2) data points to work effectively. So, if you have 8 waves you are looking for, you should have at least 10 data points.
int regression_type - the regression type is a number 1 to 4; where 1 is Linear, 2 is Logarithmic, 3 is Exponential, and 4 is Power.
int iterations - the iterations is an integer value of how many times wave data is feed back in to the Bidirectional Mean Averaging function. It's has the effect of smoothing the wave more with more iterations. values can be anything 1 or greater.
double degree_precision - the degree precision is to what decimal point are the degree of averaging carried out to. valid values are .1, .01, .001, ... down to the smallest possible level the computer is capable of handling.
int algorithm - the algorithm is an integer value that determines what kind of algorithm is applied during optimization in both amplitude and frequency. 1 uses both amplitude and frequency, 2 uses only amplitude, and 3 uses only frequency.
double rms_ratio - the rms ratio is a decimal point value. it's range is 0.0 < rms_ratio < 1.0 and determines the wave output amplitude relative to the wave amplitude of the data input using a Root Mean Square value. the smaller the number the less wave height of the output BMA wave.
double amplitude_frequency_ratio - the amplitude to frequency ratio is a decimal point value. it's range is 0.0 <= amplitude_frequency_ratio <= 1.0 and determines the proportion of how much amplitude optimization and frequency optimization is applied to the BMA wave. 0.0 means mostly frequency optimization, 0.5 means half from each optimization, and 1.0 means mostly amplitude optimization.
int number_of_waves - the number of waves is an interger value and means just that, how many wave to generate from the array.
Here's an example C# code:
private void some_sub_1()
{
Random random = new Random();
int n_items = 100;
double[] datarray = new double[n_items];
for (int a = 0; a < n_items; a++)
{
datarray[a] = 1000.0f * random.NextDouble();
}
int number_of_waves = 12;
double[][] wavematrix = new double[number_of_waves + 3][];
for (int b = 0; b < (number_of_waves + 3); b++)
{
wavematrix[b] = new double[n_items];
}
int regression_type = 1;
int iterations = 12;
double degree_precision = 0.001;
int algorithm = 1;
double rms_ratio = 0.69;
double amplitude_frequency_ratio = 0.50;
wavematrix = Functions.TheWaveMatrix(datarray, regression_type, iterations, degree_precision, algorithm, rms_ratio, amplitude_frequency_ratio, number_of_waves);
double regression_a_value = wavematrix[0][0];
double regression_b_value = wavematrix[0][1];
double wave_1_degree_value = wavematrix[0][1 + 1];
double wave_2_degree_value = wavematrix[0][2 + 1];
double wave_3_degree_value = wavematrix[0][3 + 1];
double wave_4_degree_value = wavematrix[0][4 + 1];
double wave_5_degree_value = wavematrix[0][5 + 1];
double wave_6_degree_value = wavematrix[0][6 + 1];
double wave_7_degree_value = wavematrix[0][7 + 1];
double wave_8_degree_value = wavematrix[0][8 + 1];
double wave_9_degree_value = wavematrix[0][9 + 1];
double wave_10_degree_value = wavematrix[0][10 + 1];
double wave_11_degree_value = wavematrix[0][11 + 1];
double wave_12_degree_value = wavematrix[0][12 + 1];
double[] regression_values = wavematrix[1];
double[] wave_1_values = wavematrix[1 + 1];
double[] wave_2_values = wavematrix[2 + 1];
double[] wave_3_values = wavematrix[3 + 1];
double[] wave_4_values = wavematrix[4 + 1];
double[] wave_5_values = wavematrix[5 + 1];
double[] wave_6_values = wavematrix[6 + 1];
double[] wave_7_values = wavematrix[7 + 1];
double[] wave_8_values = wavematrix[8 + 1];
double[] wave_9_values = wavematrix[9 + 1];
double[] wave_10_values = wavematrix[10 + 1];
double[] wave_11_values = wavematrix[11 + 1];
double[] wave_12_values = wavematrix[12 + 1];
double[] remainder_values = wavematrix[13 + 1];
}
The One Over None
I Know... -
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineSome of you might be wondering why we're doing this.
It's because it is one of the most dangerous things you can do, Disseminate Knowledge.
It's the foundation of freedom.Spread the word.
The One Over None
I Know... -
Hi Jade,
Very impressive work.
I wanted to ask, I installed the first link and it went great, but I couldn't install the second and of course the third update ?Message say " An error occurred during customization install "
Would it be possible to have only one link with all updates included ? this might install at ones in my computer ?
I'm running on windows XP Excel 07.
Thank you in advance if it's possible for you to do ?
Frenchie.
-
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineQuote: Originally posted by frenchie on Nov 24, 2012
Hi Jade,
Very impressive work.
I wanted to ask, I installed the first link and it went great, but I couldn't install the second and of course the third update ?Message say " An error occurred during customization install "
Would it be possible to have only one link with all updates included ? this might install at ones in my computer ?
I'm running on windows XP Excel 07.
Thank you in advance if it's possible for you to do ?
Frenchie.
you might need to uninstall the addin from the 'add and remove programs' control panel / folder, then do the install again.
when you do the uninstall then install, just do it once.
the links are all the same and the setup files are at the latest level.
The One Over None
I Know... -
Native American Eagle SunMN
United States
Member #21
December 7, 2001
4,811 Posts
OfflineQuote: Originally posted by JADELottery on Nov 23, 2012
We'll post the code first.
It's being presented in both C# and VB.
C#
----------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace YourOwnNameSpace
{
public class Functions
{
public static double TheUltimateWavePredictor(double[] array, int level)
{
double sum = 0;
for (int i = 0; i < array.Length; i++) sum += Math.Pow(-1, i) * Combinatorial(array.Length + level - 1, i + level) * array[array.Length - i - 1];
return sum / Combinatorial(array.Length + level - 2, level - 1);
}
public static double[][] TheWaveMatrix(double[] array, int regression_type, int iterations, double degree_precision, int algorithm, double rms_ratio, double amplitude_frequency_ratio, int number_of_waves)
{
int items = array.Length;
double[][] matrix = new double[2][];
matrix[0] = new double[2];
matrix[1] = new double[items];
double[][] wavematrix = new double[3 + number_of_waves][];
for (int i = 0; i < (3 + number_of_waves); i++)
{
wavematrix[i] = new double[items];
}
for (int i = 1; i < (2 + number_of_waves); i++)
{
if (i == 1)
{
matrix = Regression(array, regression_type);
wavematrix[0][0] = matrix[0][0];
wavematrix[0][1] = matrix[0][1];
wavematrix[i] = matrix[1];
}
else
{
matrix = BMAWave(array, iterations, degree_precision, algorithm, rms_ratio, amplitude_frequency_ratio);
wavematrix[0][i] = matrix[0][0];
wavematrix[i] = matrix[1];
}
for (int j = 0; j < items; j++)
{
wavematrix[i + 1][j] = array[j] = array[j] - wavematrix[i][j];
}
}
return wavematrix;
}
public static double[][] Regression(double[] array, int regression_type)
{
double a = 0;
double b = 0;
double x = 0;
double y = 0;
int items = array.Length;
double[][] regression_array = new double[2][];
regression_array[0] = new double[2] { a, b };
regression_array[1] = new double[items];
for (int i = 0; i < items; i++)
{
regression_array[1][i] = 0;
}
double sum_x = 0;
double sum_y = 0;
double sum_xx = 0;
double sum_xy = 0;
for (int i = 0; i < items; i++)
{
if (regression_type == 1) { x = i + 1; y = array[i]; } //Linear
if (regression_type == 2) { x = Math.Log(i + 1); y = array[i]; } //Logarithmic
if (regression_type == 3) { x = i + 1; y = Math.Log(array[i]); } //Exponential
if (regression_type == 4) { x = Math.Log(i + 1); y = Math.Log(array[i]); } //Power
sum_x += x;
sum_y += y;
sum_xx += x * x;
sum_xy += x * y;
}
double avg_x = sum_x / items;
double avg_y = sum_y / items;
double avg_xx = sum_xx / items;
double avg_xy = sum_xy / items;
b = (avg_xy - avg_x * avg_y) / (avg_xx - avg_x * avg_x);
if ((regression_type == 1) || (regression_type == 2)) a = avg_y - (b * avg_x);
if ((regression_type == 3) || (regression_type == 4)) a = Math.Exp(avg_y - (b * avg_x));
for (int i = 0; i < items; i++)
{
if (regression_type == 1) regression_array[1][i] = a + b * (i + 1);
if (regression_type == 2) regression_array[1][i] = a + b * Math.Log(i + 1);
if (regression_type == 3) regression_array[1][i] = a * Math.Exp(b * (i + 1));
if (regression_type == 4) regression_array[1][i] = a * Math.Pow((i + 1), b);
}
regression_array[0][0] = a;
regression_array[0][1] = b;
return regression_array;
}
public static double[][] BMAWave(double[] array, int iterations, double degree_precision, int algorithm, double rms_ratio, double amplitude_frequency_ratio)
{
int items = array.Length;
double amplitude_degree;
double frequency_degree;
double amplitude_degree_precision;
double frequency_degree_precision;
bool optimal_found;
bool optimal;
bool last_optimal_state;
double[][] wave = new double[2][];
wave[0] = new double[2] { 0, 0 };
wave[1] = new double[items];
wave[1] = array;
amplitude_degree = 0;
if ((algorithm == 1) || (algorithm == 2))
{
amplitude_degree_precision = 1;
optimal_found = false;
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio);
last_optimal_state = optimal;
do
{
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio);
if (!optimal && !last_optimal_state)
{ amplitude_degree -= amplitude_degree_precision; }
else if (!optimal && last_optimal_state)
{ amplitude_degree -= amplitude_degree_precision; amplitude_degree_precision *= 0.1; }
else if (optimal && !last_optimal_state)
{ amplitude_degree += amplitude_degree_precision; amplitude_degree_precision *= 0.1; }
else if (optimal && last_optimal_state)
{ amplitude_degree += amplitude_degree_precision; }
if (optimal && (amplitude_degree_precision <= degree_precision)) optimal_found = true;
if (Math.Abs(amplitude_degree) >= 100) optimal_found = true;
last_optimal_state = optimal;
}
while (!optimal_found);
}
frequency_degree = 0;
if ((algorithm == 1) || (algorithm == 3))
{
frequency_degree_precision = 1;
optimal_found = false;
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations));
last_optimal_state = optimal;
do
{
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations));
if (!optimal && !last_optimal_state)
{ frequency_degree -= frequency_degree_precision; }
else if (!optimal && last_optimal_state)
{ frequency_degree -= frequency_degree_precision; frequency_degree_precision *= 0.1; }
else if (optimal && !last_optimal_state)
{ frequency_degree += frequency_degree_precision; frequency_degree_precision *= 0.1; }
else if (optimal && last_optimal_state)
{ frequency_degree += frequency_degree_precision; }
if (optimal && (frequency_degree_precision <= degree_precision)) optimal_found = true;
if (Math.Abs(frequency_degree) >= 100) optimal_found = true;
last_optimal_state = optimal;
}
while (!optimal_found);
}
if (algorithm == 1) wave[0][0] = amplitude_frequency_ratio * amplitude_degree + (1 - amplitude_frequency_ratio) * frequency_degree;
if (algorithm == 2) wave[0][0] = amplitude_degree;
if (algorithm == 3) wave[0][0] = frequency_degree;
wave[1] = BMAIteration(array, wave[0][0], iterations);
wave[0][0] = Math.Round(wave[0][0], (int)Math.Abs(Math.Log10(degree_precision)));
return wave;
}
public static bool WaveAmplitudeOptimal(double[] array, double[] BMA_array, double rms_ratio)
{
bool optimal = false;
int itmes = array.Length;
double array_sqr_sum = 0;
double BMA_array_sqr_sum = 0;
double RMS_array = 0;
double RMS_BMA_array = 0;
for (int i = 0; i < itmes; i++)
{
array_sqr_sum += array[i] * array[i];
BMA_array_sqr_sum += BMA_array[i] * BMA_array[i];
}
RMS_array = Math.Sqrt(array_sqr_sum / (double)itmes);
RMS_BMA_array = Math.Sqrt(BMA_array_sqr_sum / (double)itmes);
if ((RMS_array / RMS_BMA_array) > (1.0 / rms_ratio))
{ optimal = true; }
else
{ optimal = false; }
return optimal;
}
public static bool WaveFrequencyOptimal(double[] array)
{
bool optimal = false;
int items = array.Length;
int[] frequency = new int[items];
int[] diff_frequency = new int[items - 1];
int[] diff_diff_frequency = new int[items - 2];
int[] frequency_set = new int[3] { 0, 0, 0 };
for (int i = 0; i < items; i++)
{
if (array[i] > 0)
{ frequency[i] = 1; }
else
{ frequency[i] = 0; }
}
for (int i = 0; i < items - 1; i++)
{
if ((array[i + 1] - array[i]) > 0)
{ diff_frequency[i] = 1; }
else
{ diff_frequency[i] = 0; }
}
for (int i = 0; i < items - 2; i++)
{
if ((array[i + 2] - 2 * array[i + 1] + array[i]) > 0)
{ diff_diff_frequency[i] = 1; }
else
{ diff_diff_frequency[i] = 0; }
}
for (int i = 0; i < frequency.Length - 1; i++)
{
frequency_set[0] += Math.Abs(frequency[i + 1] - frequency[i]);
}
for (int i = 0; i < diff_frequency.Length - 1; i++)
{
frequency_set[1] += Math.Abs(diff_frequency[i + 1] - diff_frequency[i]);
}
for (int i = 0; i < diff_diff_frequency.Length - 1; i++)
{
frequency_set[2] += Math.Abs(diff_diff_frequency[i + 1] - diff_diff_frequency[i]);
}
Array.Sort(frequency_set);
if ((frequency_set[2] - frequency_set[0]) > 3)
{ optimal = false; }
else
{ optimal = true; }
return optimal;
}
public static double[] BMAIteration(double[] array, double degree, int iterations)
{
double[] iteration_array = array;
for (int i = 0; i < iterations; i++)
{
iteration_array = BidirectionalMeanAverage(iteration_array, degree);
}
return iteration_array;
}
public static double[] BidirectionalMeanAverage(double[] array, double degree)
{
int items = array.Length;
double[] array_up = new double[items];
double[] array_down = new double[items];
double[] array_average = new double[items];
array_up[0] = array[0];
for (int i = 1; i < items; i++)
{
array_up[i] = (array_up[i - 1] + Math.Exp(degree) * array[i]) / (1 + Math.Exp(degree));
}
array_down[items - 1] = array[items - 1];
for (int i = items - 2; i > -1; i--)
{
array_down[i] = (array_down[i + 1] + Math.Exp(degree) * array[i]) / (1 + Math.Exp(degree));
}
for (int i = 0; i < items; i++)
{
array_average[i] = (array_up[i] + array_down[i]) / 2;
}
return array_average;
}
public static double Combinatorial(int n, int r)
{
try
{
return Factorial(n) / (Factorial(r) * Factorial(n - r));
}
catch
{
return 0;
}
}
public static double Factorial(int n)
{
try
{
if (n > 0)
{ return n * Factorial(n - 1); }
else
{ return 1; }
}
catch
{
return 0;
}
}
}
}
----------------------------------------------------------------------------------------------------VB
----------------------------------------------------------------------------------------------------
Imports System
Imports System.Collections.Generic
Namespace YourOwnNameSpace
Public Class Functions
Public Shared Function TheUltimateWavePredictor(array As Double(), level As Integer) As Double
Dim sum As Double = 0
For i As Integer = 0 To array.Length - 1
sum += Math.Pow(-1, i) * Combinatorial(array.Length + level - 1, i + level) * array(array.Length - i - 1)
Next
Return sum / Combinatorial(array.Length + level - 2, level - 1)
End Function
Public Shared Function TheWaveMatrix(ByVal array As Double(), ByVal regression_type As Integer, ByVal iterations As Integer, ByVal degree_precision As Double, ByVal algorithm As Integer, ByVal rms_ratio As Double, ByVal amplitude_frequency_ratio As Double, ByVal number_of_waves As Integer) As Double()()
Dim items As Integer = array.Length
Dim matrix As Double()() = New Double(1)() {}
matrix(0) = New Double(1) {}
matrix(1) = New Double(items - 1) {}
Dim wavematrix As Double()() = New Double(3 + (number_of_waves - 1))() {}
For i As Integer = 0 To (3 + number_of_waves) - 1
wavematrix(i) = New Double(items - 1) {}
Next
For i As Integer = 1 To (2 + number_of_waves) - 1
If i = 1 Then
matrix = Regression(array, regression_type)
wavematrix(0)(0) = matrix(0)(0)
wavematrix(0)(1) = matrix(0)(1)
wavematrix(i) = matrix(1)
Else
matrix = BMAWave(array, iterations, degree_precision, algorithm, rms_ratio, amplitude_frequency_ratio)
wavematrix(0)(i) = matrix(0)(0)
wavematrix(i) = matrix(1)
End If
For j As Integer = 0 To items - 1
wavematrix(i + 1)(j) = InlineAssignHelper(array(j), array(j) - wavematrix(i)(j))
Next
Next
Return wavematrix
End Function
Public Shared Function Regression(array As Double(), regression_type As Integer) As Double()()
Dim a As Double = 0
Dim b As Double = 0
Dim x As Double = 0
Dim y As Double = 0
Dim items As Integer = array.Length
Dim regression_array As Double()() = New Double(1)() {}
regression_array(0) = New Double(1) {a, b}
regression_array(1) = New Double(items - 1) {}
For i As Integer = 0 To items - 1
regression_array(1)(i) = 0
Next
Dim sum_x As Double = 0
Dim sum_y As Double = 0
Dim sum_xx As Double = 0
Dim sum_xy As Double = 0
For i As Integer = 0 To items - 1
If regression_type = 1 Then
x = i + 1
y = array(i)
End If
'Linear
If regression_type = 2 Then
x = Math.Log(i + 1)
y = array(i)
End If
'Logarithmic
If regression_type = 3 Then
x = i + 1
y = Math.Log(array(i))
End If
'Exponential
If regression_type = 4 Then
x = Math.Log(i + 1)
y = Math.Log(array(i))
End If
'Power
sum_x += x
sum_y += y
sum_xx += x * x
sum_xy += x * y
Next
Dim avg_x As Double = sum_x / items
Dim avg_y As Double = sum_y / items
Dim avg_xx As Double = sum_xx / items
Dim avg_xy As Double = sum_xy / items
b = (avg_xy - avg_x * avg_y) / (avg_xx - avg_x * avg_x)
If (regression_type = 1) OrElse (regression_type = 2) Then
a = avg_y - (b * avg_x)
End If
If (regression_type = 3) OrElse (regression_type = 4) Then
a = Math.Exp(avg_y - (b * avg_x))
End If
For i As Integer = 0 To items - 1
If regression_type = 1 Then
regression_array(1)(i) = a + b * (i + 1)
End If
If regression_type = 2 Then
regression_array(1)(i) = a + b * Math.Log(i + 1)
End If
If regression_type = 3 Then
regression_array(1)(i) = a * Math.Exp(b * (i + 1))
End If
If regression_type = 4 Then
regression_array(1)(i) = a * Math.Pow((i + 1), b)
End If
Next
regression_array(0)(0) = a
regression_array(0)(1) = b
Return regression_array
End Function
Public Shared Function BMAWave(array As Double(), iterations As Integer, degree_precision As Double, algorithm As Integer, rms_ratio As Double, amplitude_frequency_ratio As Double) As Double()()
Dim items As Integer = array.Length
Dim amplitude_degree As Double
Dim frequency_degree As Double
Dim amplitude_degree_precision As Double
Dim frequency_degree_precision As Double
Dim optimal_found As Boolean
Dim optimal As Boolean
Dim last_optimal_state As Boolean
Dim wave As Double()() = New Double(1)() {}
wave(0) = New Double(1) {0, 0}
wave(1) = New Double(items - 1) {}
wave(1) = array
amplitude_degree = 0
If (algorithm = 1) OrElse (algorithm = 2) Then
amplitude_degree_precision = 1
optimal_found = False
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio)
last_optimal_state = optimal
Do
optimal = WaveAmplitudeOptimal(array, BMAIteration(array, amplitude_degree, iterations), rms_ratio)
If Not optimal AndAlso Not last_optimal_state Then
amplitude_degree -= amplitude_degree_precision
ElseIf Not optimal AndAlso last_optimal_state Then
amplitude_degree -= amplitude_degree_precision
amplitude_degree_precision *= 0.1
ElseIf optimal AndAlso Not last_optimal_state Then
amplitude_degree += amplitude_degree_precision
amplitude_degree_precision *= 0.1
ElseIf optimal AndAlso last_optimal_state Then
amplitude_degree += amplitude_degree_precision
End If
If optimal AndAlso (amplitude_degree_precision <= degree_precision) Then
optimal_found = True
End If
If Math.Abs(amplitude_degree) >= 100 Then
optimal_found = True
End If
last_optimal_state = optimal
Loop While Not optimal_found
End If
frequency_degree = 0
If (algorithm = 1) OrElse (algorithm = 3) Then
frequency_degree_precision = 1
optimal_found = False
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations))
last_optimal_state = optimal
Do
optimal = WaveFrequencyOptimal(BMAIteration(array, frequency_degree, iterations))
If Not optimal AndAlso Not last_optimal_state Then
frequency_degree -= frequency_degree_precision
ElseIf Not optimal AndAlso last_optimal_state Then
frequency_degree -= frequency_degree_precision
frequency_degree_precision *= 0.1
ElseIf optimal AndAlso Not last_optimal_state Then
frequency_degree += frequency_degree_precision
frequency_degree_precision *= 0.1
ElseIf optimal AndAlso last_optimal_state Then
frequency_degree += frequency_degree_precision
End If
If optimal AndAlso (frequency_degree_precision <= degree_precision) Then
optimal_found = True
End If
If Math.Abs(frequency_degree) >= 100 Then
optimal_found = True
End If
last_optimal_state = optimal
Loop While Not optimal_found
End If
If algorithm = 1 Then
wave(0)(0) = amplitude_frequency_ratio * amplitude_degree + (1 - amplitude_frequency_ratio) * frequency_degree
End If
If algorithm = 2 Then
wave(0)(0) = amplitude_degree
End If
If algorithm = 3 Then
wave(0)(0) = frequency_degree
End If
wave(1) = BMAIteration(array, wave(0)(0), iterations)
wave(0)(0) = Math.Round(wave(0)(0), CInt(Math.Truncate(Math.Abs(Math.Log10(degree_precision)))))
Return wave
End Function
Public Shared Function WaveAmplitudeOptimal(array As Double(), BMA_array As Double(), rms_ratio As Double) As Boolean
Dim optimal As Boolean = False
Dim itmes As Integer = array.Length
Dim array_sqr_sum As Double = 0
Dim BMA_array_sqr_sum As Double = 0
Dim RMS_array As Double = 0
Dim RMS_BMA_array As Double = 0
For i As Integer = 0 To itmes - 1
array_sqr_sum += array(i) * array(i)
BMA_array_sqr_sum += BMA_array(i) * BMA_array(i)
Next
RMS_array = Math.Sqrt(array_sqr_sum / CDbl(itmes))
RMS_BMA_array = Math.Sqrt(BMA_array_sqr_sum / CDbl(itmes))
If (RMS_array / RMS_BMA_array) > (1.0 / rms_ratio) Then
optimal = True
Else
optimal = False
End If
Return optimal
End Function
Public Shared Function WaveFrequencyOptimal(array__1 As Double()) As Boolean
Dim optimal As Boolean = False
Dim items As Integer = array__1.Length
Dim frequency As Integer() = New Integer(items - 1) {}
Dim diff_frequency As Integer() = New Integer(items - 2) {}
Dim diff_diff_frequency As Integer() = New Integer(items - 3) {}
Dim frequency_set As Integer() = New Integer(2) {0, 0, 0}
For i As Integer = 0 To items - 1
If array__1(i) > 0 Then
frequency(i) = 1
Else
frequency(i) = 0
End If
Next
For i As Integer = 0 To items - 2
If (array__1(i + 1) - array__1(i)) > 0 Then
diff_frequency(i) = 1
Else
diff_frequency(i) = 0
End If
Next
For i As Integer = 0 To items - 3
If (array__1(i + 2) - 2 * array__1(i + 1) + array__1(i)) > 0 Then
diff_diff_frequency(i) = 1
Else
diff_diff_frequency(i) = 0
End If
Next
For i As Integer = 0 To frequency.Length - 2
frequency_set(0) += Math.Abs(frequency(i + 1) - frequency(i))
Next
For i As Integer = 0 To diff_frequency.Length - 2
frequency_set(1) += Math.Abs(diff_frequency(i + 1) - diff_frequency(i))
Next
For i As Integer = 0 To diff_diff_frequency.Length - 2
frequency_set(2) += Math.Abs(diff_diff_frequency(i + 1) - diff_diff_frequency(i))
Next
Array.Sort(frequency_set)
If (frequency_set(2) - frequency_set(0)) > 3 Then
optimal = False
Else
optimal = True
End If
Return optimal
End Function
Public Shared Function BMAIteration(array As Double(), degree As Double, iterations As Integer) As Double()
Dim iteration_array As Double() = array
For i As Integer = 0 To iterations - 1
iteration_array = BidirectionalMeanAverage(iteration_array, degree)
Next
Return iteration_array
End Function
Public Shared Function BidirectionalMeanAverage(array As Double(), degree As Double) As Double()
Dim items As Integer = array.Length
Dim array_up As Double() = New Double(items - 1) {}
Dim array_down As Double() = New Double(items - 1) {}
Dim array_average As Double() = New Double(items - 1) {}
array_up(0) = array(0)
For i As Integer = 1 To items - 1
array_up(i) = (array_up(i - 1) + Math.Exp(degree) * array(i)) / (1 + Math.Exp(degree))
Next
array_down(items - 1) = array(items - 1)
For i As Integer = items - 2 To -1 + 1 Step -1
array_down(i) = (array_down(i + 1) + Math.Exp(degree) * array(i)) / (1 + Math.Exp(degree))
Next
For i As Integer = 0 To items - 1
array_average(i) = (array_up(i) + array_down(i)) / 2
Next
Return array_average
End Function
Public Shared Function Combinatorial(n As Integer, r As Integer) As Double
Try
Return Factorial(n) / (Factorial(r) * Factorial(n - r))
Catch
Return 0
End Try
End Function
Public Shared Function Factorial(n As Integer) As Double
Try
If n > 0 Then
Return n * Factorial(n - 1)
Else
Return 1
End If
Catch
Return 0
End Try
End Function
End Class
End Namespace
----------------------------------------------------------------------------------------------------it appears we didn't copy all the code in the VB section.
you'll need to add the following function in the Functions class.
VB
---------------------Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function---------------------
The One Over None
I Know... -
Thank you Jade,
I installed the latest link without no problem, not sure how to use it but I will find out.Frenchie.
-
How many draws for the nm 5/37? Would 15 to 20 be good?
I'm sitting here listening to Merle Haggard sipping some coffee!