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

Unnecessarily convoluted code #48

Open
yairdaon opened this issue Apr 2, 2024 · 0 comments
Open

Unnecessarily convoluted code #48

yairdaon opened this issue Apr 2, 2024 · 0 comments

Comments

@yairdaon
Copy link

yairdaon commented Apr 2, 2024

In examples/inference/ex08-optimal_design.ipynb in the fifth code cell the following lines appear:

make a fltr to get Is for each age class

fltr1=np.kron([[0, 0, 0, 1]], np.identity(M))
obs1=np.einsum('ij,kj->ki', fltr1, x)

This is a very interesting way of writing
obs1 = x[:,-2:]

Verify:

import numpy as np
M = 2
x = np.random.randn(200, 4*M)

fltr1=np.kron([[0, 0, 0, 1]], np.identity(M))
np.all(np.einsum('ij,kj->ki', fltr1, x) == x[:,-2:])

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

No branches or pull requests

1 participant