Skip to content

Instantly share code, notes, and snippets.

@jsams
Created January 21, 2019 20:34
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 jsams/c3635de3179518b2ee0b62644ab5ee26 to your computer and use it in GitHub Desktop.
Save jsams/c3635de3179518b2ee0b62644ab5ee26 to your computer and use it in GitHub Desktop.
jessica's slowdown
function getprobs(x, a, b)
ea = exp.(x * a)
eb = exp.(x * b)
denom = 1 .+ ea .+ eb
proba = ea ./ denom
probb = eb ./ denom
return proba, probb, 1 .- proba, 1 .- probb
end
N = 5000000
P = 25
X = randn(N, P)
A = rand(P)
B = rand(P)
@time ans = getprobs(X, A, B); #0.5s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment