<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Priors for Bayesian analysis
Astromodels supports the definition of priors for all parameters in your model. You can use as prior any function (although of course not all functions should be used this way, but the choice is up to you).
First let's define a simple model containing one point source (see the "Model tutorial" for more info)
Step1:  Now let's assign uniform priors to the parameters of the powerlaw function. The function uniform_prior is defined like this
Step2:  We can use it as such
Step3:  Now we can evaluate the prior simply as
Step4:  Let's plot the value of the prior at some random locations
<ASSISTANT_TASK:>
Python Code:
from astromodels import *
# Create a point source named "pts1"
pts1 = PointSource('pts1',ra=125.23, dec=17.98, spectral_shape=powerlaw())
# Create the model
my_model = Model(pts1)
Explanation: Priors for Bayesian analysis
Astromodels supports the definition of priors for all parameters in your model. You can use as prior any function (although of course not all functions should be used this way, but the choice is up to you).
First let's define a simple model containing one point source (see the "Model tutorial" for more info):
End of explanation
uniform_prior.info()
Explanation: Now let's assign uniform priors to the parameters of the powerlaw function. The function uniform_prior is defined like this:
End of explanation
# Set 'lower_bound' to -10, 'upper bound' to 10, and leave the 'value' parameter 
# to the default value
pts1.spectrum.main.powerlaw.K.prior = log_uniform_prior(lower_bound = 1e-15, upper_bound=1e-7)
# Display it
pts1.spectrum.main.powerlaw.K.display()
# Set 'lower_bound' to -10, 'upper bound' to 0, and leave the 'value' parameter 
# to the default value
pts1.spectrum.main.powerlaw.index.prior = uniform_prior(lower_bound = -10, upper_bound=0)
pts1.spectrum.main.powerlaw.index.display()
Explanation: We can use it as such:
End of explanation
# Create a short cut to avoid writing too much
po = pts1.spectrum.main.powerlaw
# Evaluate the prior in 2.3e-5
point = 2.3e-21
prior_value1 = po.K.prior(point * po.K.unit)
# Equivalently we can use the fast call with no units
prior_value2 = po.K.prior.fast_call(point)
assert prior_value1 == prior_value2
print("The prior for logK evaluate to %s in %s" % (prior_value1, point))
Explanation: Now we can evaluate the prior simply as:
End of explanation
# You need matplotlib installed for this
import matplotlib.pyplot as plt
# This is for the IPython notebook
%matplotlib inline
# Let's get 500 points uniformly distributed between -20 and 20
random_points = np.logspace(-30,2,50)
plt.loglog(random_points,pts1.spectrum.main.powerlaw.K.prior.fast_call(random_points), '.' )
#plt.xscale("log")
#plt.ylim([-0.1,1.2])
plt.xlabel("value of K")
plt.ylabel("Prior")
Explanation: Let's plot the value of the prior at some random locations:
End of explanation
<END_TASK>