简体   繁体   English

Excel中的公式-对数平均值

[英]Formula in Excel - Logarithmic Average

I need to implement this equation: 我需要实现以下等式:

对数和

In c# it is pretty straightforward: 在C#中非常简单:

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. 我需要在Excel表格中以编程方式打印出数据的方式来验证数据。 That is the raw data, my c# calculations on the raw data AND the excel formual that should match my c# calculations. 那就是原始数据,我对原始数据的c#计算以及应该与我的c#计算匹配的excel形式。 I just do not know how to write the formula in excel. 我只是不知道如何在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: 因此,例如,如果我需要算术平均值,即:

算术平均值

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? 还是我需要用Excel编写什么?

without VBA: 没有VBA:

Put your data in A1 through A10 and in B1 enter: 将数据放入A1A10,然后在B1中输入:

=10^(A1/10)

and copy down. 然后抄下来 Then in another cell enter: 然后在另一个单元格中输入:

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

在此处输入图片说明

You can avoid the "helper" column (column B ) by using: 您可以使用以下方法来避免使用“帮助程序”列B列)

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

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: 即在列上使用for循环并填写:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM