You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cell In[18], line 3, in sample_f(shocks)
1 def sample_f(shocks):
----> 3 return shocks["gamma"] * np.array([2,4])
ValueError: operands could not be broadcast together with shapes (7,) (2,)
The issue being that the full grid of the discretized distribution is being passed (in a dictionary, 'labeled' form) to the function sample_f, instead of one value being passed in at a time. This doesn't typically raise an error, but it does when the function includes an array operation.
I believe these different functions in HARK.distribution were written by different people, so many it's a matter of harmonizing them.
The text was updated successfully, but these errors were encountered:
Oh, this looks like it's because of the difference between expected and calc_expectations. expected wants the function passed to it to take... the whole vector of probability atoms?
It says "This function should take the full array of distribution values
and return either arrays of arbitrary shape or scalars."
That doesn't make sense to me... the values of either the probabilities or the realized values isn't enough to compute the expected value, and there isn't an argument for both.
I see this is widely used in the HARK models but the docs don't make sense to me. Can somebody explain?
There's something funky about how a few of our distribution operations work together.
The following code calls on several features in
HARK.distribution
:DiscreteDistributionLabeled
combine_indep_dstns
expected
and breaks unexpectedly.
discretized_shock_dstn
creates aDiscreteDistributionLabeled
class for each shock passed in (as a dictionary), and then combines them. See here: https://github.com/econ-ark/HARK/blob/master/HARK/model.py#L44Then the following code breaks:
This produces an error:
The issue being that the full grid of the discretized distribution is being passed (in a dictionary, 'labeled' form) to the function
sample_f
, instead of one value being passed in at a time. This doesn't typically raise an error, but it does when the function includes an array operation.I believe these different functions in
HARK.distribution
were written by different people, so many it's a matter of harmonizing them.The text was updated successfully, but these errors were encountered: