Skip to content

Possibly confusing .~ meaning #435

@ParadaCarleton

Description

@ParadaCarleton

From the previous issue on calculations for pointwise_loglikelihood:

What do you expect pointwise_loglikelihoods to compute here? The marginal likelihood for each dimension? If so, I don't think this is what you want for something like LOO-PIS.

EDIT: If y is a Matrix, it makes a bit more sense, and in that case you can use either a for loop or .~ (for MultvariateDistribution, .~ assumes each column represents an observation).

I'm unsure if this is the most intuitive behavior. The problem here is that, in general, the rows of a table represent independent observations, while each column is a different attribute. My suggestion would be to use the following set of rules for .~ broadcasting:

  1. If the object being broadcasted over is a table from Tables.jl and is not an Array, Turing should recognize that each row is an independent observation for the purposes of pointwise_loglikelihood and any similar functions. (Although internally, it should be treated as a broadcast over columns -- this should improve performance, since columns usually have only one type.)
  2. If the object is an array, not from Tables.jl, and not square, broadcasting over columns is safe -- .~ will throw a dimension mismatch if the user meant to broadcast over rows. We can assume the user meant to broadcast over columns because Julia is column major without risking too much.
  3. If the object being broadcasted over is square and not a Table, or if it is both a Table and an Array, an error should be thrown.

This is annoying given Julia is column-major, but I think it's the best solution to avoid errors in data analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions