title: What does log_prob do?
body: <p>In some (e.g. machine learning) libraries, we can find <code>log_prob</code> function. What does it do and how is it different from taking just regular <code>log</code>?</p>
  
  <p>For example, what is the purpose of this code:</p>
  
  <pre><code>dist = Normal(mean, std)
  sample = dist.sample()
  logprob = dist.log_prob(sample)
  </code></pre>
  
  <p>And subsequently, why would we first take a log and then exponentiate the resulting value instead of just evaluating it directly:</p>
  
  <pre><code>prob = torch.exp(dist.log_prob(sample))
  </code></pre>