Formula in Excel - Logarithmic Average

4.3k views Asked by At

I need to implement this equation:

Logarithmic Sum

In c# it is pretty straightforward:

static double LogarithmicSummed(IReadOnlyList<double> values)
{
    double outVal = 0;
    for (int i = 0; i < values.Count; i++)
    {
        outVal = outVal + Math.Pow(10, values[i] / 10);
    }
    return 10 * Math.Log10(outVal);
} 

I need to verify the data in an excel sheet where I print out the data programmatically. That is the raw data, my c# calculations on the raw data AND the excel formual that should match my c# calculations. I just do not know how to write the formula in excel.

I know the rows and columns where the data are and they are next to each other. So for example, if I needed the arithmetic average, ie:

Arithmetic average

I could print out for each row:

// If row = 1, startColumn = A, endColumn = D, noOfColumn = 4. This would print: =SUM(A1:D1)/4
mean[row] = @"=SUM(" + startColumn + row + ":" + endColumn + row + ")/" + noOfColumns;

What would I print out to match the first formula I wrote? Or what would I need to write in Excel?

2

There are 2 answers

3
Gary's Student On BEST ANSWER

without VBA:

Put your data in A1 through A10 and in B1 enter:

=10^(A1/10)

and copy down. Then in another cell enter:

=10*LOG10(SUM(B1:B10))

enter image description here

You can avoid the "helper" column (column B) by using:

=10*LOG10(SUMPRODUCT(10^((A1:A10)/10)))
0
Blindy On

If that's how you enter your formulas, then why not use the literal form of the sum? Ie use a for loop over the columns and fill in:

10*log(10^(A1/10)+10^(A2/10)+10^(A3/10)+10^(A4/10))