How are meandB and sddB derived for the functions in r?

12 views
Skip to first unread message

David Schutt

unread,
Oct 6, 2023, 9:53:24 AM10/6/23
to seewave
I'm getting a different value when I use the meandB function in r than when I use the formula =10*LOG10(AVERAGE(10^(B**:B**/10))) to calculate the mean in Excel.

Thanks!

Jérôme SUEUR

unread,
Oct 9, 2023, 5:36:11 AM10/9/23
to seewave GROUP
Hello,
Just type in the R console the name of the function. This will return the code and so the math used.
HTH
Best
Jerome

> meandB
function (x, level = "IL") 
{
    if (level == "IL") {
        a <- 10
    }
    else {
        a <- 20
    }
    return(a * log10(mean(10^(x/a))))
}

> sddB
function (x, level = "IL") 
{
    if (level == "IL") {
        a <- 10
    }
    else {
        a <- 20
    }
    x <- 10^(x/a)
    res <- a * (sd(x)/(mean(x) * log(10)))
    return(res)
}


De: "David Schutt" <da...@penguinsinternational.org>
À: "seewave GROUP" <see...@googlegroups.com>
Envoyé: Vendredi 6 Octobre 2023 15:53:24
Objet: [seewave] How are meandB and sddB derived for the functions in r?

I'm getting a different value when I use the meandB function in r than when I use the formula =10*LOG10(AVERAGE(10^(B**:B**/10))) to calculate the mean in Excel.
Thanks!

--
You received this message because you are subscribed to the Google Groups "seewave" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seewave+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/seewave/a155bd21-28c0-448c-9fae-97a6372bc6can%40googlegroups.com.

David Schutt

unread,
Oct 12, 2023, 10:47:54 PM10/12/23
to seewave
Great, thank you!
Reply all
Reply to author
Forward
0 new messages