File:Dirichlet kernels.svg
From testwiki
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 720 × 495 pixels. Other resolution: 2,560 × 1,760 pixels.
Original file (SVG file, nominally 720 × 495 pixels, file size: 57 KB)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionDirichlet kernels.svg |
English: Plots of the first few Dirichlet kernels made with matplotlib. This function has a period of 2π. |
||
| Date | |||
| Source | Dirichlet.png | ||
| Author |
|
||
| Other versions |
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Source code
Source Code in python:
|
|---|
from __future__ import division # In case someone wants to use Python 2
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns # Just for the colors
mpl.rcParams['axes.labelsize'] = 20
mpl.rcParams['axes.titlesize'] = 22
mpl.rcParams['legend.fontsize'] = 18
mpl.rcParams['xtick.labelsize'] = 14
mpl.rcParams['ytick.labelsize'] = 14
mpl.rcParams['lines.linewidth'] = 3
def dirichlet(n, x):
return np.where(x!=0, np.sin((n + .5)*x)/np.sin(.5*x), 2*n + 1)
points = 2**10 + 1
kernels = 4
x_min = -np.pi
x_max = np.pi
x_vals = np.linspace(x_min, x_max, num=points)
n_vals = np.arange(1, kernels + 1)
D = dirichlet(np.resize(n_vals, (points, kernels)).T,
np.resize(x_vals, (kernels, points)))
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
for kernel, n in zip(D, n_vals):
ax.plot(x_vals, kernel,
label=r'$\frac{\sin((' + str(n) + r'+1/2)x)}{\sin(x/2)}$')
ax.xaxis.set_ticks(np.pi*np.arange(-4, 5)/4)
ax.xaxis.set_ticklabels([r'$-\pi$', r'$-\frac{3\pi}{4}$', r'$-\frac{\pi}{2}$',
r'$-\frac{\pi}{4}$', r'$0$', r'$\frac{\pi}{4}$',
r'$\frac{\pi}{2}$', r'$\frac{3\pi}{4}$', r'$\pi$'])
ax.legend()
ax.set_xlim([x_min, x_max])
ax.set_xlabel(r'$x$')
ax.set_ylabel(r'$D_n(x)$')
ax.xaxis.grid(color='gray')
ax.yaxis.grid(color='gray')
plt.tight_layout()
plt.savefig('dirichlet.svg')
|
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
21 November 2014
58,585 byte
image/svg+xml
4d0ab7b44ae165cf091ded575dc2e50183c3cedd
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 22:38, 21 November 2014 | No thumbnail | 720 × 495 (57 KB) | wikimediacommons>Azaghal of Belegost | User created page with UploadWizard |
File usage
The following page uses this file: