#NEWLINE# def _setup_linear_regression( ) : #NEWLINE# #INDENT# '\n    Setup code for the pdf and contour tests.\n\n    This code is from http://www.bayespy.org/examples/regression.html\n    ' #NEWLINE# np . random . seed ( 1 ) #NEWLINE# k = 2 #NEWLINE# c = 5 #NEWLINE# s = 2 #NEWLINE# x = np . arange ( 10 ) #NEWLINE# y = ( ( ( k * x ) + c ) + ( s * np . random . randn ( 10 ) ) ) #NEWLINE# X = np . vstack ( [ x , np . ones ( len ( x ) ) ] ) . T #NEWLINE# B = GaussianARD ( 0 , 1e-06 , shape = ( 2 , ) ) #NEWLINE# F = SumMultiply ( 'i,i' , B , X ) #NEWLINE# tau = Gamma ( 0.001 , 0.001 ) #NEWLINE# Y = GaussianARD ( F , tau ) #NEWLINE# Y . observe ( y ) #NEWLINE# Q = VB ( Y , B , tau ) #NEWLINE# Q . update ( repeat = 1000 ) #NEWLINE# xh = np . linspace ( ( - 5 ) , 15 , 100 ) #NEWLINE# Xh = np . vstack ( [ Y , np . ones ( len ( xh ) ) ] ) . T #NEWLINE# Fh = SumMultiply ( 'i,i' , B , Xh ) #NEWLINE# return locals ( )