<jupyter_start><jupyter_text>Harr 小波基<jupyter_code>import numpy as np
def haarMatrix(n, normalized=False):
    # Allow only size n of power 2
    n = 2**np.ceil(np.log2(n))
    if n > 2:
        h = haarMatrix(n / 2)
    else:
        return np.array([[1, 1], [1, -1]])

    # calculate upper haar part
    h_n = np.kron(h, [1, 1])
    # calculate lower haar part 
    if normalized:
        h_i = np.sqrt(n/2)*np.kron(np.eye(len(h)), [1, -1])
    else:
        h_i = np.kron(np.eye(len(h)), [1, -1])
    # combine parts
    h = np.vstack((h_n, h_i))
    return h
haarbasis = haarMatrix(8, normalized=False)
import matplotlib.pyplot as plt
fig,axs = plt.subplots(8)
fig.suptitle('Haar basis', size=10)
for i in range(8):
    x = [0,1,2,3,4,5,6,7]
    axs[i].bar(x,haarbasis[i])<jupyter_output><empty_output><jupyter_text>离散余弦变换基<jupyter_code>from scipy.fftpack import dct
dctbasis = dct(np.eye(8), axis=0)
fig1,axs1 = plt.subplots(8)
fig1.suptitle('DCT basis', size=10)
for i in range(8):
    x = [0,1,2,3,4,5,6,7]
    axs1[i].bar(x,dctbasis[i])<jupyter_output><empty_output><jupyter_text>傅里叶变换基<jupyter_code>from scipy import fft
fftbasis = fft(np.eye(8))
fig2,axs2 = plt.subplots(8)
fig2.suptitle('FFT basis real', size=10)
for i in range(8):
    x = [0,1,2,3,4,5,6,7]
    axs2[i].bar(x,fftbasis.real[i])
fig3,axs3 = plt.subplots(8)
fig3.suptitle('FFT basis image', size=10)
for i in range(8):
    x = [0,1,2,3,4,5,6,7]
    axs3[i].bar(x,fftbasis.imag[i])
from matplotlib import cm
rho = 0.95
S = np.zeros([8,8])
for i in range(8):
    for j in range(8):
        S[i,j] = rho**np.abs(i-j)
plt.imshow(S)
_, PCAbasis = np.linalg.eig(S)
fig4,axs4 = plt.subplots(8)
fig4.suptitle('PCA basis', size=10)
for i in range(8):
    x = [0,1,2,3,4,5,6,7]
    axs4[i].bar(x,PCAbasis.T[i])
S
v<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1860850358917725, 'fraction_numerical': 0.05687465488680287, 'mean_word_length': 3.8972972972972975, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '138028', 'license': 'MIT', 'n_tokens_mistral': 912, 'n_tokens_neox': 894, 'n_words': 162, 'path': '10. Principal Component Analysis/.ipynb_checkpoints/Untitled-checkpoint.ipynb', 'repo_name': 'haitaozhao/PRSL', 'size': '1811'}