Skip to content

Instantly share code, notes, and snippets.

@twiecki
Last active August 26, 2021 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twiecki/6b13d0880f8307e7613cd174e963b8cd to your computer and use it in GitHub Desktop.
Save twiecki/6b13d0880f8307e7613cd174e963b8cd to your computer and use it in GitHub Desktop.
def z_link_func(x, data=mydata):
stim = (np.asarray(dmatrix('0 + C(s, [[0], [1]])',
{'s': data.stimulus.loc[x.index]}))
)
# Apply z = (1 - x) to flip them along 0.5
z_flip = stim - x
# The above inverts those values we do not want to flip,
# so invert them back
z_flip[stim == 0] *= -1
return z_flip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment