Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clipped exponential distribution. #779

Merged
merged 3 commits into from
Nov 25, 2015
Merged

Add clipped exponential distribution. #779

merged 3 commits into from
Nov 25, 2015

Conversation

jgosmann
Copy link
Collaborator

@jgosmann jgosmann commented Jul 9, 2015

This distribution is useful for thresholding in ensembles. It performs better than a uniform distribution of intercepts or setting all intercepts exactly to the threshold.

download
blue: fixed intercepts
green: uniform
red: exponential distribution
The ideal function would be a step function going from 0 to 1 at 0.3 (plus synaptic filtering).

I am planning to update the AssociativeMemory to use this distribution and maybe implement a thresholding network.

@xchoo
Copy link
Member

xchoo commented Jul 9, 2015

Oh. I'm working on the AssociativeMemory thing right now. 😄

@jgosmann
Copy link
Collaborator Author

jgosmann commented Jul 9, 2015

I know of that problem, but I am not sure whether to add that tolerance in the distribution or wherever it is used (the required tolerance might depend on the usage?)

@xchoo
Copy link
Member

xchoo commented Jul 13, 2015

Can we add the tolerance as a parameter in the constructor?

@jgosmann
Copy link
Collaborator Author

We could ...

@hunse
Copy link
Collaborator

hunse commented Jul 13, 2015

Or we could just use the minimum tolerance for the type:

high = np.nextafter(self.high, np.asarray(-np.inf, dtype=exp_val.dtype))

@jgosmann
Copy link
Collaborator Author

This might be the best solution. I didn't know about nextafter (it doesn't seem to be in the Numpy documentation).

@xchoo
Copy link
Member

xchoo commented Jul 13, 2015

Indeed. This is the first time i've seen nextafter. 😄

@hunse
Copy link
Collaborator

hunse commented Jul 24, 2015

This seems fine to me. At some point, we might need to move some of the more esoteric distributions in dists.py somewhere else; for example, this one could maybe go with the SPA stuff if it's mostly being used there. That would keep dists.py more for distributions that users are going to use. But I'm fine putting this in dists.py for now.

@jgosmann
Copy link
Collaborator Author

this one could maybe go with the SPA stuff if it's mostly being used there

I don't think that this distribution is specific to the SPA. You could as well build a scalar thresholding ensemble with it. Also, I don't think, that an exponential distribution is very esoteric. But I could see moving the SqrtBeta stuff around.

@hunse
Copy link
Collaborator

hunse commented Aug 22, 2015

This needs a changelog entry. Maybe mention briefly what it's useful for?

It would also be great to have a notebook example showing it off, but we can add this down the road. (Maybe have one notebook documenting all distributions? Though I feel like Gaussian and Uniform are more self-explanatory.) Also at some point we might want to consider building the Laplace distribution into this class (or making it a subclass or something), since it's very similar and takes the same parameters. (At the moment I'm not sure if the Laplace distribution is actually useful for anything we do, which is why I'm not suggesting this for now.)

@hunse
Copy link
Collaborator

hunse commented Aug 22, 2015

Oh, also write the PDF in the docstring. You can probably copy it from the Numpy exponential distribution docstring, though frankly I'm not totally keen on all the LaTeX in their formatting, because it makes it hard to read if you just open the docstring in Python.

EDIT: I know we don't do this for other distributions (maybe we should), but I just thought of it here because right now it's not clear what the "scale" parameter is (not that the math will totally help with that). Alternatively, you could think of a way to describe the scale parameter; it does handily correspond to the mean of the distribution, so maybe it's enough to say that? Though if they add a shift, then the mean is going to be the scale plus the shift. Either way, I don't think it would be bad to have the math as well, since it's a less common distribution (and just from the name, I actually couldn't remember if it was the single-sided one (which it is) or the double-sided Laplace distribution).

@Seanny123
Copy link
Contributor

@hunse added the docs you requested. Is this now ready to merge?

@hunse
Copy link
Collaborator

hunse commented Nov 25, 2015

Okay, I fixed up the docstring more. Can somebody look that over?

@jgosmann
Copy link
Collaborator Author

LGTM

jgosmann and others added 2 commits November 25, 2015 16:07
Previously, the `Exponential` distribution produced values
in the range [low, high]. It now produces values
in the range [low, high), to ensure that intercepts
right at the radius of an ensemble are not generated.
@hunse
Copy link
Collaborator

hunse commented Nov 25, 2015

@jgosmann and I talked, and decided to change the name of this distribution to Exponential (rather than ClippedExpDist), since if high is not set it can be used as a normal Exponential distribution.

@hunse hunse merged commit c8e0ba0 into master Nov 25, 2015
@hunse hunse deleted the expdist branch November 25, 2015 21:13
@tbekolay
Copy link
Member

👍 for exponential -- I was also going to mention that the Dist at the end is likely redundant based on context, so happy this got changed :)

As a sidenote, I've been using this distribution a lot lately for inhibitory populations, and it's extremely useful. Thanks @jgosmann! Now I can switch back to master!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants