import numpy as np import random def channel(x): G = 10 sigma2 = 10 s = random.choice([1, 2]) n = x.size Y = np.random.normal(0, np.sqrt(sigma2), n) if s == 1: x_even = np.array(x[::2]) * np.sqrt(G) x_odd = x[1::2] else: x_even = np.array(x[::2]) x_odd = x[1::2] * np.sqrt(G) Y[::2] += x_even Y[1::2] += x_odd return Y