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

Error in calculating the mean values in the FData object #642

Open
aleexarias opened this issue Jan 12, 2025 · 0 comments · May be fixed by #643
Open

Error in calculating the mean values in the FData object #642

aleexarias opened this issue Jan 12, 2025 · 0 comments · May be fixed by #643
Assignees
Labels

Comments

@aleexarias
Copy link

Bug description summary

In the FData class, the mean function is calculated with the sum function, which has a skipna option that ignores NaN values. However, for the division it is assumed that all elements are present, which could not be correct in all cases.

Code to reproduce the bug

from skfda.representation.grid import FDataGrid

data_matrix = np.array([
    [1.0, 2.0, 3.0],
    [np.nan, 2.0, 3.0],
    [1.0, 2.0, np.nan],
])

fd = FDataGrid(data_matrix)
mean_fd = fd.mean(skipna=True)

print("Computed mean with skipna=True:")
print(mean_fd.data_matrix)

Expected result

Computed mean with skipna=True:
[ 1.0 2.0 3.0]

Actual result

Computed mean with skipna=True:
[ 0.66 2.0 2.0]

Traceback (if an exception is raised)

No response

Software versions

scikit-fda version: 0.9.2.dev0
OS: Ubuntu 20.04.6 LTS (Focal Fossa)

Additional context

No response

@aleexarias aleexarias added the bug label Jan 12, 2025
@aleexarias aleexarias linked a pull request Jan 13, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant