.. _sphx_glr_auto_examples_Elements_plot_frequency_scale.py: ================ Frequency Scale ================ Illustration of the different frequency scales .. code-block:: python from simplecochlea.utils import utils_cochlea import matplotlib.pyplot as plt import seaborn as sns sns.set() sns.set_context('paper') Suppose we want a cochlea whose frequency domain range from 20 Hz to 20000 Hz with 100 hair cells Each hair cell can be modeled as a band-pass filter. Each one selecting a certain frequency range. An important parameter is the way these band-pass filters are organized and cover the whole frequency range of hearing. .. code-block:: python fmin, fmax = 20, 20000 n_filters = 100 fs = 44100 A unrealistic but simple way to organize the band-pass filters is to use a *linear scale*. The :func:`utils_cochlea.linearscale` returns both the filters cutoff and center frequencies .. code-block:: python wn_lin, cf_lin = utils_cochlea.linearscale(fs, fmin, fmax, n_filters) A more realistic solution to model the tonotopy of the cochlea is to use the ERB scale (Equivalent Rectangular Bandwitdh) : .. code-block:: python wn_erb, cf_erb = utils_cochlea.erbscale(fs, fmin, fmax, n_filters) Let's plot the evolution of the center frequencies for both scales : .. code-block:: python f = plt.figure() ax = f.add_subplot(111) ax.stem(cf_lin, markerfmt='C0o') ax.stem(cf_erb, markerfmt='C1o') ax.set(xlabel='Filter Number', ylabel='Frequency', title='Evolution of the Center Frequency of Bandpass filters') ax.legend(['Linear Scale', 'ERB Scale']) .. image:: /auto_examples/Elements/images/sphx_glr_plot_frequency_scale_001.png :align: center **Total running time of the script:** ( 0 minutes 3.047 seconds) .. only :: html .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: plot_frequency_scale.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_frequency_scale.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_