<s> '''<STR_LIT>''' <EOL> from __future__ import division <EOL> import numpy as np <EOL> def normalize ( data ) : <EOL> '''<STR_LIT>''' <EOL> mean = np . mean ( data ) <EOL> sd = np . sqrt ( np . var ( data ) ) <EOL> z_data = ( data - mean ) / sd <EOL> return z_data <EOL> def convert_slope ( x_data , y_data , zb1_sample ) : <EOL> '''<STR_LIT>''' <EOL> y_sd = np . sqrt ( np . var ( y_data ) ) <EOL> x_sd = np . sqrt ( np . var ( x_data ) ) <EOL> b1 = zb1_sample * ( y_sd / x_sd ) <EOL> return b1 <EOL> def convert_intercept ( x_data , y_data , zb0_sample , zb1_sample ) : <EOL> '''<STR_LIT>''' <EOL> y_sd = np . sqrt ( np . var ( y_data ) ) <EOL> y_mean = np . mean ( y_data ) <EOL> x_sd = np . sqrt ( np . var ( x_data ) ) <EOL> x_mean = np . mean ( x_data ) <EOL> b0 = zb0_sample * y_sd + y_mean - zb1_sample * ( y_sd * x_mean ) / x_sd <EOL> return b0 <EOL> def convert_tau_sigma ( y_data , ztau_sample ) : <EOL> '''<STR_LIT>''' <EOL> z_sigma = <NUM_LIT:1> / np . sqrt ( ztau_sample ) <EOL> y_sd = np . sqrt ( np . var ( y_data ) ) <EOL> sigma = z_sigma * y_sd <EOL> return sigma <EOL> def convert_sigma ( y_data , zsigma_sample ) : <EOL> '''<STR_LIT>''' <EOL> y_sd = np . sqrt ( np . var ( y_data ) ) <EOL> sigma = zsigma_sample * y_sd <EOL> return sigma <EOL> def convert_baseline ( a0_sample , a_sample , x_levels , y_data ) : <EOL> '''<STR_LIT>''' <EOL> m_sample = a0_sample . repeat ( x_levels ) . reshape ( len ( a0_sample ) , x_levels ) + a_sample <EOL> b0_sample = m_sample . mean ( axis = <NUM_LIT:1> ) <EOL> b0_sample = b0_sample * np . sqrt ( np . var ( y_data ) + np . mean ( y_data ) ) <EOL> return b0_sample <EOL> def convert_deflection ( a0_sample , a_sample , x_levels , y_data ) : <EOL> '''<STR_LIT>''' <EOL> m_sample = a0_sample . repeat ( x_levels ) . reshape ( len ( a0_sample ) , x_levels ) + a_sample <EOL> b0_sample = m_sample . mean ( axis = <NUM_LIT:1> ) <EOL> b_sample = ( m_sample - <EOL> b0_sample . repeat ( x_levels ) . reshape ( len ( b0_sample ) , x_levels ) ) <EOL> b_sample = b_sample * np . sqrt ( np . var ( y_data ) ) <EOL> return b_sample </s>
