<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Commonly used filter banks: DCT, Chroma, Mel, CQT"""

import numpy as np
import scipy.signal
import librosa
from builtins import range


def dct(n_filters, n_input):
    """Discrete cosine transform (DCT) basis

    :usage:
        >>> # Compute MFCCs
        >>> S           = librosa.melspectrogram(y, sr)
        >>> dct_filters = librosa.filters.dct(13, S.shape[0])
        >>> mfcc        = dct_filters.dot(librosa.logamplitude(S))

    :parameters:
      - n_filters : int > 0 [scalar]
          number of output components (DCT filters)

      - n_input : int > 0 [scalar]
          number of input components (frequency bins)

    :returns:
      - dct_basis: np.ndarray [shape=(n_filters, n_input)]
          DCT basis vectors

    """

    basis = np.empty((n_filters, n_input))
    basis[0, :] = 1.0 / np.sqrt(n_input)

    samples = np.arange(1, 2*n_input, 2) * np.pi / (2.0 * n_input)

    for i in range(1, n_filters):
        basis[i, :] = np.cos(i*samples) * np.sqrt(2.0/n_input)<commit_msg>Verified and documented DCT code. Fixes #130<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Commonly used filter banks: DCT, Chroma, Mel, CQT"""

import numpy as np
import scipy.signal
import librosa
from builtins import range


def dct(n_filters, n_input):
    """Discrete cosine transform (DCT type-III) basis.

    .. seealso:: http://en.wikipedia.org/wiki/Discrete_cosine_transform

    :usage:
        >>> # Compute MFCCs
        >>> S           = librosa.melspectrogram(y, sr)
        >>> dct_filters = librosa.filters.dct(13, S.shape[0])
        >>> mfcc        = dct_filters.dot(librosa.logamplitude(S))

    :parameters:
      - n_filters : int > 0 [scalar]
          number of output components (DCT filters)

      - n_input : int > 0 [scalar]
          number of input components (frequency bins)

    :returns:
      - dct_basis: np.ndarray [shape=(n_filters, n_input)]
          DCT (type-III) basis vectors

    """

    basis = np.empty((n_filters, n_input))
    basis[0, :] = 1.0 / np.sqrt(n_input)

    samples = np.arange(1, 2*n_input, 2) * np.pi / (2.0 * n_input)

    for i in range(1, n_filters):
        basis[i, :] = np.cos(i*samples) * np.sqrt(2.0/n_input)
{'fraction_non_alphanumeric': 0.14292015880017644, 'fraction_numerical': 0.016321129245699163, 'mean_word_length': 2.5492957746478875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3348487', 'n_tokens_mistral': 855, 'n_tokens_neox': 802, 'n_words': 195}