Skip to content

combine_indep_dstns fails with Bernoulli distributions #1572

@sbenthall

Description

@sbenthall

Describe the bug
combine_indep_dstns fails with Bernoulli distributions.

To Reproduce
There are two distinct but perhaps related bugs.
First, the Bernoulli distribution has no dim() method:

b = Bernoulli(p=0.5)
combine_indep_dstns(*[b])

gets you:

File "/home/sb/projects/HARK/HARK/distributions/utils.py", line 406, in combine_indep_dstns
    if len(dist.dim()) > 1:
           ^^^^^^^^
AttributeError: 'Bernoulli' object has no attribute 'dim'

Next, if you wrap this in a DiscreteDistributionLabeled, that also fails:

bl = DiscreteDistributionLabeled.from_unlabeled(Bernoulli(p=0.5), var_names='b')
combine_indep_dstns(*[bl])

gets you:

  File "/home/sb/projects/HARK/HARK/distributions/utils.py", line 447, in <listcomp>
    [distributions[i].limit["infimum"] for i in range(dstn_count)]
     ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'infimum'

Expected behavior
That these should "construct [the] joint discrete distribution" of the input Bernoulli, which is just the same Bernoulli.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions