def eliminate2(n): u2 = 50 * random(x0, z, n) u1 = random(1.7231 * x0, z - 2, n) list = [] for i in range(len(u2)): if u2[i] <= fin2(u1[i]): list.append(u1[i]) return list
def eliminateCauchy(n): u2 = 0.35 * random(0.1423123, 13, n) u1 = 4 * random(0.1221321, 11, n) - 8 list = [] for i in range(len(u2)): if u2[i] <= finCauchy(u1[i]): list.append(u1[i]) return list
def eliminate1(n): u2 = random(x0, z, n) u1 = 2 * random(1.7231 * x0, z - 2, n) - 1 list = [] for i in range(len(u2)): if u2[i] <= fin1(u1[i]): list.append(u1[i]) return list
def eliminate_cauchy_upgraded(n): tmplist = [] num_of_elements = 0 i = 0 u2 = 0.35 * random(0.1231231213, 11, 5 * n) u1 = 10 * random(0.1221321, 11, 5 * n) - 5 while (num_of_elements < n): if u2[i] <= finCauchy(u1[i]): tmplist.append(u1[i]) num_of_elements += 1 i += 1 return tmplist
def eliminate41(n): tmplist = [] d = 2 num_of_elements = 0 i = 0 u2 = d * random(0.1231231213, 11, 3 * n) u1 = random(0.14421322321, 15, 3 * n) while (num_of_elements < n): if u2[i] <= function41(u1[i]): tmplist.append(u1[i]) num_of_elements += 1 i += 1 return tmplist
def eliminate4(n, x00): c = sqrt(2 * np.e / np.pi) V = f4(n) U = random(x00, z, n) list = [] for i in range(len(V)): if np.fabs(V[i]) <= sqrt(-2 * np.log(U[i])) + 1: list.append(V[i]) return list
import numpy as np import matplotlib.pyplot as plt from labgotowe import random from lab5 import rectangular_kernel, epanechnikov_kernel, boscar_kernel A = 1 N = 500 Z = np.random.normal(0, 1, N) X = 4 * random(0.14123216, 15, N) - 2 x_sorted = sorted(X) Q = 100 def m_function(a, x): return np.arctan(a * x) def m_function_all(a, tab): output = [] for i in range(len(tab)): output.append(m_function(a, tab[i])) return output def system_output(x_tab, z_tab): output = [] for x in range(len(x_tab)): output.append(m_function(A, x_tab[x]) + z_tab[x]) return output def valid(kernel_type, x_tab, y_tab, hv):
if __name__ == "__main__": N = 200 h = 1 M = 100 L = 10 normal_tab = normal_generator(N) random_tab = random(0.13213421, 13, N) print(normal_generator(10)) fig1, ax1 = plt.subplots(3) x1, y1 = kernel_estimator("rectangular", normal_tab, 0.4, N) ax1[0].plot(x1, y1) ax1[0].set_title('h = 0.4') x2, y2 = kernel_estimator("rectangular", normal_tab, 1, N) ax1[1].plot(x2, y2) ax1[1].set_title('h = 1') x3, y3 = kernel_estimator("rectangular", normal_tab, 4, N) ax1[2].plot(x3, y3) ax1[2].set_title('h = 4') fig2, ax2 = plt.subplots(3) x4, y4 = kernel_estimator("rectangular", normal_tab, h, N) ax2[0].plot(x4, y4) ax2[0].set_title('Rozkład normalny - jądro prostokątne')
import numpy as np import matplotlib.pyplot as plt from labgotowe import random from lab5 import rectangular_kernel, epanechnikov_kernel, boscar_kernel A = 1 N = 250 L = 15 Q = 100 x_tab = 2 * np.pi * random(0.14123141, 15, N) - np.pi x_sorted = sorted(x_tab) z_tab = np.random.normal(0, 1, 500) def m7_function(a, x): if 0 <= abs(x) < 1: tmp = a * pow(x, 2) elif 1 <= abs(x) < 2: tmp = 1 else: tmp = 0 return tmp def m7_for_tab(a, tab): output = [] for i in range(len(tab)): output.append(m7_function(a, tab[i])) return output