Skip to content

Investigate when BetaUnivariate raises an error and how to fix it #455

@fealho

Description

@fealho

Error Description

It is possible for the BetaUnivariate to raise an error when fitting to some data:

from copulas.univariate import BetaUnivariate
BetaUnivariate().fit(np.array([0.7122827 , 0.04830956, 0.54410219, 0.04173127, 0.54462469, 0.54565197, 0.05497849, 0.07792652, 0.6817948 , 0.19735519]))

# Fails with the following:
scipy.stats._warnings_errors.FitError: Optimization converged to parameters that are outside the range allowed by the distribution.

The error happens when fitting the univariate in the following line:

a, b, loc, scale = beta.fit(X, loc=loc, scale=scale)

Expected Behavior

Investigate what causes scipy to fail and what can be done to improve the convergence rate.

Additional Context

This happens because "scipy.stats.fit doesn't guarantee success".

Note: On the rare occasion when this error happens, the synthesizers - either in Copulas or in SDV - would still work, since they have a fallback distribution for such cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions