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 SqrtBeta probability distribution #430

Merged
merged 1 commit into from
Feb 18, 2015
Merged

Add SqrtBeta probability distribution #430

merged 1 commit into from
Feb 18, 2015

Conversation

jgosmann
Copy link
Collaborator

This addresses #414.

I uploaded the derivation of the probability distribution to the Google drive.

I am unsure whether to add the PDF/CDF. I think, those are useful, but we're not providing those functions for the other probability distributions.

@jgosmann
Copy link
Collaborator Author

I added the PDF and CDF. However, I could not think of a good way to test them (in a unit test) so far.

@hunse
Copy link
Collaborator

hunse commented Oct 28, 2014

I have a commit 967706a in another branch that does the mean and variance of UniformHypersphere components.

For this branch, something like this seems good to have, but I'm not sure if we want it as a separate distribution. Users won't be using it to distribute their parameters. Maybe we want it under the UniformHypersphere class (i.e., add pdf, mean, and variance attributes kind of like I've done in 967706a).

@jgosmann
Copy link
Collaborator Author

I'm not sure if I get what you are saying. Do you propose to add a mean and a variance function to SqrtBeta? And what exactly do you think we might move to the UniformHypersphere class?

@hunse
Copy link
Collaborator

hunse commented Oct 28, 2014

Take a look at my commit.

The whole point of having the SqrtBeta class is that this is the distribution of one element of the UniformHypersphere class, right? I.e. it's the marginal distribution of UniformHypersphere. So why not put it there? When people use it, they will always be using it in the context of UniformHypersphere, to get the distribution of one element. It will never be used as its own stand-alone distribution.

@jgosmann
Copy link
Collaborator Author

SqrtBeta is the distribution of the absolute value of some number of subdimensions of elements sampled from the surface of a UniformHypersphere. Thus, values from SqrtBeta will always be positive but the components of vectors from a UniformHypersphere might be negative (though one could use SqrtBeta and flip coins for the sign). Also, SqrtBeta assumes sampling from the surface of the hypersphere and UniformHypersphere allows sampling within the whole sphere.

SqrtBeta is its own distribution and I am not convinced that we gain something by hiding it in some other distribution. Actually, I am using it as a stand-alone distribution in the spaopt branch.

@hunse
Copy link
Collaborator

hunse commented Oct 29, 2014

In 967706a I use the SqrtBeta distribution to calculate the mean and variance for any one dimension of the points from a UniformHypersphere distribution. Setting m = 1 and n = d - 0.5 will give you the distribution for points on the surface (where d is the dimensionality), and m = 1, n = d + 0.5 will give you the distribution for points in the sphere. So I was just trying to figure out if we could combine them. Also, for the stuff I'm doing, I don't need the Beta function, which is nice because then we don't need Scipy.

@hunse
Copy link
Collaborator

hunse commented Oct 29, 2014

If you use it by itself, then that's fine. Probably my code should be using yours, then, but I didn't want the Scipy dependency. Also, once I did it numerically I found that there are analytic forms for the mean and variance of an element of UniformHypersphere, so we can just use those.

@jgosmann
Copy link
Collaborator Author

The reason that you don't need Scipy is that you are skipping the normalization. Though, it shouldn't be too complicated to write our own approximations for beta and betainc. I just didn't care so far because the code using SqrtBeta has other dependencies on Scipy (those could also be replaced, but I don't think the code will be merged to master any time soon).

One thing I like more about my implementation is that the dimensions are passed to the constructor and I do not have to repeat them every time.

@hunse
Copy link
Collaborator

hunse commented Feb 18, 2015

I think this is good to go. It's just adding a distribution, so it should be straightforward (i.e. it can't break anything).

Also added SubvectorLength distribution based off the SqrtBeta
distribution.
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

3 participants