Author 
Message 
Don11135 science forum beginner
Joined: 24 Mar 2005
Posts: 18

Posted: Fri Jul 21, 2006 11:34 am Post subject:
Re: Help in identifying a numerical method



You're right, sum1 = sum2 = 0 to start with. The only thing I left out
is that d_i and d_j are both rounded values:
double d_i = round(x[i] / e) // to nearest integer
double d_j = round(x[j] / e) // to nearest integer
highegg wrote:
Quote:  Don wrote:
I was provided with some code for refining the estimate of a initial
value, but I have no clue to what class of numerical method this
belongs. Any suggestions would be greatly appreciated. As you can
tell, I'm not a mathematician, just a programmer trying to understand
some code implementation.
Here's the code:
If I have an array of values, x[] and an initial estimated value e,
which all the values in the x array have a relationship to, then
double sum1, sum2
I guess you're missing
sum1 = sum2 = 0
here. Am I right?
for(i = 0; i < x.length; i++)
{
double d_i = x[i] / e
for(j = 0; j < x.length; j++)
{
double val = min(i + 1, j + 1)  ((i+1)*(j+1)) / (x.length + 1)
double d_j = x[j] / e
NOTE: at this point, d_i == x[i]/e
sum1 += val * d_j * x[i]
sum2 += val * d_j * d_i
}
}
// finally the refined value
finalValue = sum1 / sum2
At each update of sum1 and sum2, the increment for sum1 is e times the
increment for sum2.
Therefore, sum1/sum2 should be e (up to roundoff). Did you reproduce
the code correctly?
Jaroslav 


Back to top 


highegg science forum beginner
Joined: 11 Feb 2005
Posts: 5

Posted: Fri Jul 21, 2006 5:09 am Post subject:
Re: Help in identifying a numerical method



Don wrote:
Quote:  I was provided with some code for refining the estimate of a initial
value, but I have no clue to what class of numerical method this
belongs. Any suggestions would be greatly appreciated. As you can
tell, I'm not a mathematician, just a programmer trying to understand
some code implementation.
Here's the code:
If I have an array of values, x[] and an initial estimated value e,
which all the values in the x array have a relationship to, then
double sum1, sum2

I guess you're missing
sum1 = sum2 = 0
here. Am I right?
Quote: 
for(i = 0; i < x.length; i++)
{
double d_i = x[i] / e
for(j = 0; j < x.length; j++)
{
double val = min(i + 1, j + 1)  ((i+1)*(j+1)) / (x.length + 1)
double d_j = x[j] / e
NOTE: at this point, d_i == x[i]/e
sum1 += val * d_j * x[i]
sum2 += val * d_j * d_i
}
}
// finally the refined value
finalValue = sum1 / sum2
At each update of sum1 and sum2, the increment for sum1 is e times the 
increment for sum2.
Therefore, sum1/sum2 should be e (up to roundoff). Did you reproduce
the code correctly?
Jaroslav 

Back to top 


Don11135 science forum beginner
Joined: 24 Mar 2005
Posts: 18

Posted: Thu Jul 20, 2006 8:56 pm Post subject:
Help in identifying a numerical method



I was provided with some code for refining the estimate of a initial
value, but I have no clue to what class of numerical method this
belongs. Any suggestions would be greatly appreciated. As you can
tell, I'm not a mathematician, just a programmer trying to understand
some code implementation.
Here's the code:
If I have an array of values, x[] and an initial estimated value e,
which all the values in the x array have a relationship to, then
double sum1, sum2
for(i = 0; i < x.length; i++)
{
double d_i = x[i] / e
for(j = 0; j < x.length; j++)
{
double val = min(i + 1, j + 1)  ((i+1)*(j+1)) / (x.length + 1)
double d_j = x[j] / e
sum1 += val * d_j * x[i]
sum2 += val * d_j * d_i
}
}
// finally the refined value
finalValue = sum1 / sum2
In the first iteration of the j loop, the numerator is increasing by
one (1,2,3,4,5..), in the 2nd iteration, the numerator increases by 2
(2,4,6,8...), in the 3rd iteration, the numerator increases by 3
(3,6,9,12...) and so on. The net result is that val becomes some type
of weighting scheme that is applied to both sum1 and sum2. Eventually,
the final value is calculated by dividing sum1 by sum2.
It appears to me to a way to statistically refine an estimated value.
Thanks in advance,
Don 

Back to top 


Google


Back to top 



The time now is Sun Dec 11, 2016 6:02 am  All times are GMT

