Skip to content
DeepForgeby svx
All problems
HardNLPnlp-193

MFCC Coefficient Value

Problem

Return one MFCC coefficient from mel energies using the DCT-II: sum over k of log(max(E_k, 1e-10)) * cos(pi * n * (k + 0.5) / K), where K is the number of mel bands and n is the coefficient index.

Energies below 1e-10 are clamped before taking the log.

Hint

Coefficient 0 is the sum of log energies; higher coefficients oscillate with cos.

Test cases

case 1
in: [[1,1,1,1],0]
expected: 0
case 2
in: [[1,2,4,8],1]
expected: -2.1864094216025802
case 3
in: [[1,2,4,8],0]
expected: 4.1588830833596715
case 4
in: [[1],0]
expected: 0
case 5
in: [[1,2],0]
expected: 0.6931471805599453
Starter codePython
import math
def mfcc_coefficient_value(energies, n):
    # Your code here
    pass

5 test cases · run your code against them in the editor