<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import numpy as np <EOL> from scipy . special import erf <EOL> def aitchison_aitken ( h , Xi , x , num_levels = None ) : <EOL> """<STR_LIT>""" <EOL> Xi = Xi . reshape ( Xi . size ) <EOL> if num_levels is None : <EOL> num_levels = np . asarray ( np . unique ( Xi ) . size ) <EOL> kernel_value = np . ones ( Xi . size ) * h / ( num_levels - <NUM_LIT:1> ) <EOL> idx = Xi == x <EOL> kernel_value [ idx ] = ( idx * ( <NUM_LIT:1> - h ) ) [ idx ] <EOL> return kernel_value <EOL> def wang_ryzin ( h , Xi , x ) : <EOL> """<STR_LIT>""" <EOL> Xi = Xi . reshape ( Xi . size ) <EOL> kernel_value = <NUM_LIT:0.5> * ( <NUM_LIT:1> - h ) * ( h ** abs ( Xi - x ) ) <EOL> idx = Xi == x <EOL> kernel_value [ idx ] = ( idx * ( <NUM_LIT:1> - h ) ) [ idx ] <EOL> return kernel_value <EOL> def gaussian ( h , Xi , x ) : <EOL> """<STR_LIT>""" <EOL> return ( <NUM_LIT:1.> / np . sqrt ( <NUM_LIT:2> * np . pi ) ) * np . exp ( - ( Xi - x ) ** <NUM_LIT:2> / ( h ** <NUM_LIT:2> * <NUM_LIT> ) ) <EOL> def gaussian_convolution ( h , Xi , x ) : <EOL> """<STR_LIT>""" <EOL> return ( <NUM_LIT:1.> / np . sqrt ( <NUM_LIT:4> * np . pi ) ) * np . exp ( - ( Xi - x ) ** <NUM_LIT:2> / ( h ** <NUM_LIT:2> * <NUM_LIT> ) ) <EOL> def wang_ryzin_convolution ( h , Xi , Xj ) : <EOL> ordered = np . zeros ( Xi . size ) <EOL> for x in np . unique ( Xi ) : <EOL> ordered += wang_ryzin ( h , Xi , x ) * wang_ryzin ( h , Xj , x ) <EOL> return ordered <EOL> def aitchison_aitken_convolution ( h , Xi , Xj ) : <EOL> Xi_vals = np . unique ( Xi ) <EOL> ordered = np . zeros ( Xi . size ) <EOL> num_levels = Xi_vals . size <EOL> for x in Xi_vals : <EOL> ordered += aitchison_aitken ( h , Xi , x , num_levels = num_levels ) * aitchison_aitken ( h , Xj , x , num_levels = num_levels ) <EOL> return ordered <EOL> def gaussian_cdf ( h , Xi , x ) : <EOL> return <NUM_LIT:0.5> * h * ( <NUM_LIT:1> + erf ( ( x - Xi ) / ( h * np . sqrt ( <NUM_LIT:2> ) ) ) ) <EOL> def aitchison_aitken_cdf ( h , Xi , x_u ) : <EOL> x_u = int ( x_u ) <EOL> Xi_vals = np . unique ( Xi ) <EOL> ordered = np . zeros ( Xi . size ) <EOL> num_levels = Xi_vals . size <EOL> for x in Xi_vals : <EOL> if x <= x_u : <EOL> ordered += aitchison_aitken ( h , Xi , x , num_levels = num_levels ) <EOL> return ordered <EOL> def wang_ryzin_cdf ( h , Xi , x_u ) : <EOL> ordered = np . zeros ( Xi . size ) <EOL> for x in np . unique ( Xi ) : <EOL> if x <= x_u : <EOL> ordered += wang_ryzin ( h , Xi , x ) <EOL> return ordered <EOL> def d_gaussian ( h , Xi , x ) : <EOL> return <NUM_LIT:2> * ( Xi - x ) * gaussian ( h , Xi , x ) / h ** <NUM_LIT:2> <EOL> def aitchison_aitken_reg ( h , Xi , x ) : <EOL> """<STR_LIT>""" <EOL> kernel_value = np . ones ( Xi . size ) <EOL> ix = Xi != x <EOL> inDom = ix * h <EOL> kernel_value [ ix ] = inDom [ ix ] <EOL> return kernel_value <EOL> def wang_ryzin_reg ( h , Xi , x ) : <EOL> """<STR_LIT>""" <EOL> return h ** abs ( Xi - x ) </s>
