In [1]:
from sys import path
path.append('/home/bingnan/ecworkspace/HFT1')

In [2]:
import matplotlib.pyplot as plt
import seaborn as sns

In [3]:
%matplotlib inline

In [4]:
from init import *

In [7]:
x0_prop.iloc[32:]


Out[7]:
rsq_in rsq_out slope_P slope const_P const corr with Y mean std min 25% 50% 75% max
x32 0.012593 0.004479 0.000000e+00 0.098536 1.563721e-04 -0.002278 0.094170 0.005331 0.516706 -2.026272 -3.207682e-01 0.004422 3.341454e-01 1.981084
x33 0.037485 0.024064 0.000000e+00 0.111786 1.624675e-08 -0.003360 0.176089 0.013353 0.756463 -1.000000 -8.000000e-01 0.100000 9.000000e-01 1.000000
x34 0.054657 0.034020 0.000000e+00 0.148977 2.921350e-07 -0.003023 0.211363 0.005916 0.681527 -1.000000 -6.500000e-01 0.000000 6.666667e-01 1.000000
x35 0.056139 0.034573 0.000000e+00 0.158412 4.814137e-06 -0.002693 0.213798 0.002897 0.649677 -1.000000 -6.000000e-01 0.000000 6.000000e-01 1.000000
x36 0.006972 0.015099 0.000000e+00 1.660526 4.251162e-03 -0.001727 0.104972 -0.000010 0.028097 -0.531218 -1.312341e-02 0.000000 1.337027e-02 0.491824
x37 0.007539 0.010985 0.000000e+00 1.293470 5.466588e-03 -0.001678 0.097439 -0.000133 0.030172 -0.819886 -1.371007e-02 0.000000 1.381232e-02 0.456009
x38 0.013086 0.015601 0.000000e+00 1.816383 4.194454e-03 -0.001724 0.120450 0.000015 0.028221 -0.586053 -1.441199e-02 0.000000 1.446215e-02 0.364065
x39 0.014025 0.014344 0.000000e+00 2.741665 2.797050e-04 -0.002187 0.119286 0.000170 0.020478 -0.227473 -1.038361e-02 0.000000 1.047093e-02 0.324944
x40 0.010363 0.014523 0.000000e+00 2.408771 2.541182e-04 -0.002206 0.112021 0.000096 0.019996 -0.288067 -9.662981e-03 0.000000 9.612246e-03 0.306738
x41 0.010877 0.015577 0.000000e+00 2.145162 1.440139e-03 -0.001921 0.115319 0.000079 0.023440 -0.445933 -1.205707e-02 0.000000 1.208543e-02 0.343716
x42 0.001084 0.001637 3.006864e-125 0.063534 4.505705e-03 -0.001721 0.038397 0.002384 0.221671 -1.212832 -1.318046e-01 0.003954 1.384451e-01 1.138966
x43 0.003796 0.002481 0.000000e+00 0.252876 3.454921e-03 -0.001769 0.056615 0.001647 0.111206 -0.738249 -6.010550e-02 0.000624 6.452087e-02 0.802034
x44 0.002922 0.003283 0.000000e+00 0.104812 4.222059e-04 -0.002135 0.056048 0.007355 0.247733 -1.365750 -1.402246e-01 0.007971 1.572438e-01 1.412043
x45 0.004384 0.004284 0.000000e+00 0.108536 6.183663e-04 -0.002071 0.066516 0.004282 0.261694 -1.339704 -1.574684e-01 0.005359 1.697673e-01 1.268719
x46 0.000554 0.002849 6.972247e-65 0.062691 5.447910e-04 -0.002097 0.046762 0.005244 0.190200 -1.107632 -9.547786e-02 0.006735 1.090240e-01 1.115071
x47 0.001207 0.001758 3.365239e-139 0.045301 4.219238e-03 -0.001734 0.039955 0.002446 0.327621 -1.448128 -1.971294e-01 0.003433 2.035180e-01 1.494480
x48 0.003236 0.003195 0.000000e+00 0.149624 3.405888e-03 -0.001773 0.057154 0.001683 0.173333 -1.177285 -8.605302e-02 0.000000 9.031007e-02 1.182892
x49 0.002829 0.003496 0.000000e+00 0.069968 9.567692e-04 -0.002000 0.056658 0.007279 0.359988 -1.643423 -2.089041e-01 0.007022 2.259238e-01 1.716797
x50 0.003707 0.004364 0.000000e+00 0.068587 1.291578e-03 -0.001947 0.064548 0.004213 0.379452 -1.600814 -2.318389e-01 0.005940 2.420133e-01 1.601556
x51 0.000396 0.002147 5.990529e-47 0.036182 1.271207e-03 -0.001954 0.040979 0.005262 0.280778 -1.351381 -1.411197e-01 0.003868 1.539879e-01 1.439747
x52 0.015780 0.009973 0.000000e+00 1.775136 3.594354e-03 -0.001751 0.114030 -0.000015 0.030728 -0.669406 -5.555669e-03 0.000000 5.504655e-03 0.381391
x53 0.020334 0.013679 0.000000e+00 6.319268 5.187640e-03 -0.001677 0.131005 -0.000025 0.009505 -0.159443 -5.908440e-03 0.000000 5.883632e-03 0.100136
x54 0.001812 -0.001907 5.057587e-208 0.120247 3.227178e-03 -0.001784 0.017994 0.000757 0.136164 -0.982159 -6.752076e-02 0.000615 7.047668e-02 0.970479
x55 0.002279 0.001779 3.287589e-261 -0.046948 3.012538e-03 -0.001796 -0.045715 -0.000393 0.483335 -3.664548 0.000000e+00 0.000000 0.000000e+00 4.001388
x56 0.010004 0.007300 0.000000e+00 -0.135979 2.074905e-03 -0.001857 -0.093692 -0.000055 0.348561 -6.465667 -2.273737e-13 0.000000 2.273737e-13 7.159021
x57 0.010267 0.010534 0.000000e+00 -0.099494 1.534660e-03 -0.001911 -0.102227 0.000238 0.491779 -7.278310 -4.547474e-13 0.000000 6.821210e-13 7.147906
x58 0.021352 0.009614 0.000000e+00 -0.310760 3.067238e-15 -0.004736 -0.125622 -0.008492 0.205834 -0.533333 -1.333333e-01 0.000000 1.333333e-01 0.533333
x59 0.015737 0.005635 0.000000e+00 -0.343559 1.211072e-16 -0.004990 -0.104851 -0.008334 0.159596 -0.500000 -1.000000e-01 0.000000 1.000000e-01 0.500000
x60 0.023344 0.013053 0.000000e+00 -0.205115 1.266251e-10 -0.003855 -0.135739 -0.009042 0.327733 -0.600000 -2.000000e-01 0.000000 2.000000e-01 0.600000
x61 0.005880 0.001320 0.000000e+00 -0.285581 3.124004e-06 -0.002820 -0.061891 -0.003151 0.120707 -0.561393 -7.919910e-02 -0.004759 7.154116e-02 0.609120
x62 0.006381 -0.003041 0.000000e+00 0.155431 9.138644e-04 -0.002004 0.050382 0.002213 0.234073 -1.342820 -1.311930e-01 0.004871 1.393951e-01 1.201704
x63 0.011538 0.002213 0.000000e+00 0.104184 1.346315e-03 -0.001932 0.085859 0.002469 0.472604 -2.300416 -2.644439e-01 0.000000 2.723456e-01 2.061524
x64 0.003077 -0.001823 0.000000e+00 0.135369 1.090501e-03 -0.001977 0.033553 0.002199 0.186246 -1.045232 -1.052631e-01 0.004644 1.133190e-01 1.070161
x65 0.006100 0.011983 0.000000e+00 2.414170 5.307385e-03 -0.001685 0.095014 -0.000019 0.017879 -0.239056 -8.596676e-03 0.000000 8.706528e-03 0.233725
x66 0.007501 0.009123 0.000000e+00 2.018742 8.510263e-03 -0.001589 0.091926 -0.000150 0.019132 -0.430980 -9.492595e-03 0.000000 9.427441e-03 0.340267
x67 0.011284 0.012977 0.000000e+00 2.636956 4.996012e-03 -0.001692 0.110822 0.000009 0.017892 -0.294545 -9.203905e-03 0.000000 9.276418e-03 0.233266
x68 0.013171 0.012066 0.000000e+00 4.229836 1.110893e-04 -0.002328 0.112625 0.000143 0.012812 -0.131110 -6.728199e-03 0.000000 6.819887e-03 0.240946
x69 0.008807 0.011324 0.000000e+00 3.419984 9.739654e-05 -0.002352 0.100755 0.000081 0.012853 -0.137953 -6.609845e-03 0.000000 6.577795e-03 0.233424
x70 0.010373 0.012423 0.000000e+00 3.304626 1.303462e-03 -0.001939 0.106919 0.000054 0.014837 -0.242700 -7.855872e-03 0.000000 7.828223e-03 0.235795
x71 0.005105 0.007440 0.000000e+00 -1.094911 3.908556e-04 -0.002145 -0.079721 -0.000159 0.031134 -0.361702 0.000000e+00 0.000000 0.000000e+00 0.250000
x72 0.006143 0.007556 0.000000e+00 -3.009261 1.415605e-04 -0.002300 -0.083019 -0.000086 0.012678 -0.237460 -6.508649e-03 0.000000 6.558969e-03 0.149889
x73 0.008162 0.008182 0.000000e+00 -0.077270 7.717035e-04 -0.002030 -0.090872 0.001333 0.524056 -0.991667 -3.750000e-01 0.000000 3.833333e-01 0.991667
x74 0.010983 0.007544 0.000000e+00 -0.147436 1.175300e-03 -0.001956 -0.096922 -0.000347 0.330196 -0.950000 0.000000e+00 0.000000 0.000000e+00 0.950000
x75 0.009496 0.009951 0.000000e+00 -0.097513 9.872748e-04 -0.001988 -0.098996 0.000232 0.455041 -0.983333 -2.000000e-01 0.000000 2.000000e-01 0.983333
x76 0.037044 0.024034 0.000000e+00 0.111544 1.056480e-07 -0.003163 0.175400 0.011560 0.753917 -1.000000 -8.000000e-01 0.100000 8.000000e-01 1.000000
x77 0.052336 0.030184 0.000000e+00 0.151946 2.897205e-05 -0.002468 0.204056 0.002146 0.653816 -1.000000 -6.000000e-01 0.000000 6.000000e-01 1.000000
x78 0.050408 0.029962 0.000000e+00 0.136487 4.788693e-07 -0.002975 0.201318 0.007192 0.715330 -1.000000 -7.333333e-01 0.033333 7.333333e-01 1.000000
x79 0.052589 0.031439 0.000000e+00 0.145412 8.123284e-07 -0.002911 0.205832 0.005300 0.684711 -1.000000 -6.666667e-01 0.000000 6.666667e-01 1.000000

In [9]:
Myols(x0['x34'], yin, yout)


                            OLS Regression Results                            
==============================================================================
Dep. Variable:                      y   R-squared:                       0.055
Model:                            OLS   Adj. R-squared:                  0.055
Method:                 Least Squares   F-statistic:                 3.020e+04
Date:                Fri, 29 Jul 2016   Prob (F-statistic):               0.00
Time:                        02:07:10   Log-Likelihood:            -2.9550e+05
No. Observations:              522387   AIC:                         5.910e+05
Df Residuals:                  522385   BIC:                         5.910e+05
Df Model:                           1                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const         -0.0030      0.001     -5.129      0.000        -0.004    -0.002
x34            0.1490      0.001    173.790      0.000         0.147     0.151
==============================================================================
Omnibus:                    13867.586   Durbin-Watson:                   0.120
Prob(Omnibus):                  0.000   Jarque-Bera (JB):            34769.001
Skew:                          -0.023   Prob(JB):                         0.00
Kurtosis:                       4.263   Cond. No.                         1.45
==============================================================================
outsample Rsquare: 0.034020
Out[9]:
<statsmodels.regression.linear_model.RegressionResultsWrapper at 0x7f0afd742850>

In [10]:
sns.distplot(x0['x34'])


Out[10]:
<matplotlib.axes.AxesSubplot at 0x7f0afd74ef90>

In [12]:
x34 = x0['x34'].copy()

In [15]:
xx = np.sign(x34) * np.log(np.abs(x34) + 10000)

In [16]:
sns.distplot(xx)


Out[16]:
<matplotlib.axes.AxesSubplot at 0x7f0afd264a10>

In [ ]: