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

Refactor (conditional) probability methods with xarray #16

Open
munichpavel opened this issue Jan 10, 2020 · 1 comment
Open

Refactor (conditional) probability methods with xarray #16

munichpavel opened this issue Jan 10, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@munichpavel
Copy link
Owner

The mental bookkeeping required to access (conditional) probability tables might be made easier by using xarray, e.g.

cpt_data_array = xr.DataArray(
        np.array([
            [0.2, 0.8],
            [0.6, 0.4]
        ]),
        dims=('X', 'U'),
        coords={'X': range(2), 'U': range(2)}
    )
cpt_data_array.sel(X=0).values
# array([0.2, 0.8])
@munichpavel munichpavel added the enhancement New feature or request label Jan 10, 2020
@munichpavel munichpavel self-assigned this Jan 10, 2020
@munichpavel
Copy link
Owner Author

munichpavel commented Jan 10, 2020

or my new favorite

cpt_array = xr.DataArray(
    np.array([
            [
                [0.3, 0.7],
                [0.7, 0.3]
            ],
           [
                [0.1, 0.9],
                [0.2, 0.8]
            ]
        ]),
    dims=('U', 'X', 'Y'),
    coords={'U': range(2), 'X': range(2), 'Y': range(2)}
)
cpt_array.sel(U=0, X=1).values
# array([0.7, 0.3])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant