Modeling with log likelihood

Hi. I want to know if Pyro supports defining model by log likelihood.

In Stan, there are two ways of modeling,

  1. directly specifying distribution: y ~ P(data, param) e.g. 1.1 Linear regression | Stan User’s Guide
  2. accumulating log likelihood: target += log_prob(data, param) e.g. 5.3 Summing out the responsibility parameter | Stan User’s Guide

The first method is equivalent to Pyro’s pyro.sample. Does Pyro also support the second way?

yes, see pyro.factor statements. example