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

Improve the fit of the Beta distribution: Use the new loc and scale #317

Closed
npatki opened this issue Apr 7, 2022 · 0 comments · Fixed by #319
Closed

Improve the fit of the Beta distribution: Use the new loc and scale #317

npatki opened this issue Apr 7, 2022 · 0 comments · Fixed by #319
Assignees
Labels
internal The issue doesn't change the API or functionality
Milestone

Comments

@npatki
Copy link

npatki commented Apr 7, 2022

Problem Description

In the beta univariate fit function, we perform the following steps:

  1. Estimate the loc and scale parameters
  2. Call the scipy fit function using the loc and scale as starting guesses
  3. After the fit is complete, get the values for a and b

The issue is that step 3 also returns new loc and scale parameters. The ones we input are just starting guesses. When we use the same loc and scale as step 1, they are out-of-sync with the a and b parameters.

Expected behavior

Stop using the initial guesses for loc and scale. Update them when setting a and b.

i.e. change line 30

def _fit(self, X):
        loc = np.min(X)
        scale = np.max(X) - loc
        a, b, loc, scale = beta.fit(X, loc=loc, scale=scale)
        self._params = {
            'loc': loc,
            'scale': scale,
            'a': a,
            'b': b
        }

Additional context

We verified this change by comparing our fit distribution to scipy. Scipy's fit is better because it's actually updating the loc and scale parameters.

Sometimes it's off by a little bit --
image

Sometimes, by a lot --
image

@npatki npatki added the feature request Request for a new feature label Apr 7, 2022
@fealho fealho added internal The issue doesn't change the API or functionality and removed feature request Request for a new feature labels May 10, 2022
@fealho fealho added this to the 0.7.0 milestone May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal The issue doesn't change the API or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants