aimalz / prob-z

working with probabilistic redshifts
2 stars 2 forks source link

why does logmvn() return a function and not a value? #17

Closed davidwhogg closed 9 years ago

davidwhogg commented 9 years ago

just wondering

aimalz commented 9 years ago

I have my own function to generate random samples from an arbitrary distribution when I can't use the built-in numpy/scipy random samplers that only work on specific distributions. In this case the prior is one of those convenient distributions so I don't actually need the function, but leaving it in means I won't have to change the structure too much when I replace the prior with something else.

davidwhogg commented 9 years ago

I don't understand this answer. Why do you have a a logmvn()(x) call?

davidwhogg commented 9 years ago

that is, why don't you just structure your code so you have a logmvn(x)?

aimalz commented 9 years ago

I previously used the lambda function shorthand to do the same thing but expanded it for readability when debugging. Is that what's confusing? I wanted logmvn(x) to return a function of x distinct from logpdf(x) returning the value of the PDF, and the funny structure of logmvn()(x) was the way I did that.

davidwhogg commented 9 years ago

I just don't understand why you need the thing to return a function. I think this might be slowing things down. But let's work on the speed issues first...

aimalz commented 9 years ago

Okay, I concede this one. I can't think of any reason why I realistically need this, and without it I can evaluate 8e4 samples in under 2 seconds.

davidwhogg commented 9 years ago

SICK. Please point me to the new profile.

aimalz commented 9 years ago

I'm closing this issue because it's been resolved I'll continue posting profiling updates in the relevant issue.