Log uniform prior

[3]:
# Parameters
func_name = "Log_uniform_prior"
positive_prior = True

Description

[5]:
func.display()
  • description: A function which is K/x on the interval lower_bound - upper_bound and 0 outside the interval. The extremes of the interval are NOT counted as part of the interval. Lower_bound must be >= 0.
  • formula: $ f(x)=K~\begin{cases}0 & x \le \text{lower_bound} \\\frac{1}{x} & \text{lower_bound} < x < \text{upper_bound} \\ 0 & x \ge \text{upper_bound} \end{cases}$
  • parameters:
    • lower_bound:
      • value: 1e-20
      • desc: Lower bound for the interval
      • min_value: 1e-30
      • max_value: inf
      • unit:
      • is_normalization: False
      • delta: 1e-21
      • free: True
    • upper_bound:
      • value: 100.0
      • desc: Upper bound for the interval
      • min_value: 1e-30
      • max_value: inf
      • unit:
      • is_normalization: False
      • delta: 10.0
      • free: True
    • K:
      • value: 1.0
      • desc: Normalization
      • min_value: None
      • max_value: None
      • unit:
      • is_normalization: False
      • delta: 0.1
      • free: False

Shape

The shape of the function.

If this is not a photon model but a prior or linear function then ignore the units as these docs are auto-generated

[6]:
fig, ax = plt.subplots()


ax.plot(energy_grid, func(energy_grid), color=blue, lw=3)

ax.set_xlabel("x")
ax.set_ylabel("probability")

[6]:
Text(0, 0.5, 'probability')
../_images/notebooks_Log_uniform_prior_8_1.png

Random Number Generation

This is how we can generate random numbers from the prior.

[7]:


u = np.random.uniform(0,1, size=5000) draws = [func.from_unit_cube(x) for x in u] fig, ax = plt.subplots() ax.hist(draws, color=green, bins=50) ax.set_xlabel("value") ax.set_ylabel("N")

[7]:
Text(0, 0.5, 'N')
../_images/notebooks_Log_uniform_prior_10_1.png