In [1]:
from __future__ import division
import numpy as np

from locore import Sparse

In [2]:
n = 10
q = 7
Phi = np.random.randn(q,n)
sp = Sparse(Phi)

In [3]:
x = zeros((n,1))
x[1] = 1
x[5] = 1

In [4]:
sp.tangent_model(x)


Out[4]:
array([[ 0.,  0.],
       [ 1.,  0.],
       [ 0.,  0.],
       [ 0.,  0.],
       [ 0.,  0.],
       [ 0.,  1.],
       [ 0.,  0.],
       [ 0.,  0.],
       [ 0.,  0.],
       [ 0.,  0.]])

In [5]:
sp.ic(x)


Out[5]:
0.7847583117077146

In [6]:
plt.plot(sp.linearized_precertificate(x))


Out[6]:
[<matplotlib.lines.Line2D at 0x1060271d0>]

In [7]:
sigma = 0.05
y = np.dot(Phi, x) + sigma * np.random.randn(q,1)
plot(y)


Out[7]:
[<matplotlib.lines.Line2D at 0x1060ba890>]

In [8]:
sp.solve_l2(1.5 * sigma, y)


Out[8]:
array([[-0.        ],
       [ 0.97656684],
       [-0.        ],
       [ 0.        ],
       [-0.00316994],
       [ 0.94982242],
       [-0.00464396],
       [ 0.        ],
       [ 0.01143151],
       [-0.        ]])

In [9]:
sp.solve_noiseless(y)


Out[9]:
array([[ -4.44089210e-16],
       [  1.03696597e+00],
       [  3.88578059e-16],
       [  6.41370360e-03],
       [ -3.26021106e-02],
       [  9.82487863e-01],
       [ -5.82050053e-02],
       [ -6.66133815e-16],
       [  2.71410228e-02],
       [  3.47995764e-02]])