Greg Borenstein's NoMM Page

Constrained Optimization

16.1) Given a point (x0, y0), find the closest point on the line y = ax+b by minimizing the distance d^2 = (x0 - x)^2 + (y0 - y)^2 subject to the constraint y - ax - b = 0.


16.5) Compressed sensing...

Two signals with random frequencies and amplitudes. Drawn separately:

Combined:

Code for plots here: compressed_sensing_signal_plot.py

Now sample a random subset

import numpy as np import matplotlib.pyplot as plt import random # for sampling n = 100 # number of random samples maxA = 10 # maxAmplitude f1 = np.random.random_sample() f2 = np.random.random_sample() a1 = np.random.random_sample() * maxA a2 = np.random.random_sample() * maxA # combined signal x = np.linspace(-5,5, 1000) y = a1 * np.sin(2* np.pi * f1 *x) + a2 * np.sin(2* np.pi * f2 *x) # combine x,y into 1000x2 matrix points = np.column_stack([x,y]) # select random sample of n rows sample = points[np.random.randint(0, points.shape[0]-1, size=n), :]