Skip to content

Incorrect result: adding two numbers from discrete() where the sum is more than the int size specified in the discrete() #67

@lisaoakley

Description

@lisaoakley

Minimal example:

let r0 = discrete(0.9,0.1) in
let r1 = discrete(0.9,0.1) in
r0 + r1

Expected:

[{"Joint Distribution":[["Value","Probability"],["0","0.81"],["1","0.18000000000000005"],["2","0.010000000000000004"]]}]

Or a type error of some kind telling me this is not possible.

Actual:

{"Joint Distribution":[["Value","Probability"],["0","0.82000000000000006"],["1","0.18000000000000005"]]}]

Workaround:

let r0 = discrete(0.9,0.1,0) in
let r1 = discrete(0.9,0.1,0) in
r0 + r1

Output:

[{"Joint Distribution":[["Value","Probability"],["0","0.81"],["1","0.18000000000000005"],["2","0.010000000000000004"],["3","0"]]}]

Note that this output has an entry for '3' but this should always have probability zero. In other words, the workaround results in excess entries in the distribution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions