In [6]:
# Low-level import 
from numpy import array,loadtxt,linspace,zeros,exp,ones,unwrap,angle,pi
# Setup ipython environment
%load_ext autoreload
%autoreload 2
%matplotlib inline
# Import useful things from kerr
from kerr import qnmfit,rgb,ndflatten
# Import usefult things from nrutils
from nrutils import scsearch,gwylm,scbuild,jf14067295,Mf14067295
# Setup plotting backend
import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 0.8
mpl.rcParams['font.family'] = 'serif'
mpl.rcParams['font.size'] = 12
mpl.rcParams['axes.labelsize'] = 20
from matplotlib.pyplot import *
from numpy import *


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

In [14]:
close('all')
x0 = linspace(-0.5,0.5,15)
y0 = array(x0)
u0 = array(x0)
x = x0 + 0.08*(random.random( x0.shape )-0.5)
y = y0 + 0.08*(random.random( y0.shape )-0.5)
X,Y = meshgrid(x,y)
zfun = lambda xx,yy: xx**2 + yy**2 + xx*yy + yy*xx**2

Z = zfun(X,Y) + 0.01*(random.random( X.shape )-0.5)

#
domain,scalar_range = ndflatten( [X,Y], Z )

foo = gmvpfit( domain, scalar_range, fitatol=5e-4, verbose = True, plot=True, show = True )


(gmvpfit)>> Now working deg = 1
&& The estimator has changed by -inf
&& Degree tempering will continue.
&& The current boundary is ['1', '0']
&& The current estimator value is 0.988376

(gmvpfit)>> Now working deg = 2
&& The estimator has changed by -0.825873
&& Degree tempering will continue.
&& The current boundary is ['01', '11', '00', '1']
&& The current estimator value is 0.162504

(gmvpfit)>> Now working deg = 3
&& The estimator has changed by -0.144566
&& Degree tempering will continue.
&& The current boundary is ['01', '11', '00', '001']
&& The current estimator value is 0.017937

(gmvpfit)>> Now working deg = 4
&& The estimator has changed by -0.000050
&& Degree tempering has completed becuase the estimator has changed by |-0.000050| < 0.000500. The results of the last iteration wil be kept.
&& The Final boundary is ['01', '11', '00', '001']
&& The Final estimator value is 0.017937


========================================
# Degree Tempered Positive Greedy Solution:
========================================
f = lambda x0,x1: 9.9930e-01*(x1*x1) + 9.9875e-01*(x0*x0) + 9.9749e-01*(x0*x1) + 1.0006e+00*(x0*x0*x1)

############################################
# Applying a Negative Greedy Algorithm
############################################


Iteration #1 (Negative Greedy)
------------------------------------
>> min_estimator = 2.4979e-01
>> The current boundary = ['01', '11', '00', '001']
>> Exiting because |min_est-initial_estimator_value| = |0.249795-0.017937| = |0.231858| > 0.229539.
>> NOTE that the result of the previous iteration will be kept.
========================================
# Negative Greedy Solution:
========================================
f = lambda x0,x1: 9.9930e-01*(x1*x1) + 9.9875e-01*(x0*x0) + 9.9749e-01*(x0*x1) + 1.0006e+00*(x0*x0*x1)

Fit Information:
----------------------------------------
f = lambda x0,x1: 9.9930e-01*(x1*x1) + 9.9875e-01*(x0*x0) + 9.9749e-01*(x0*x1) + 1.0006e+00*(x0*x0*x1)

In [ ]: