Description Usage Arguments Value Author(s) See Also Examples
This function converts a continuous one-dimensional distribution function (DF), such as a galaxy mass function, into a step-wise DF on an arbitrary number of bins.
1 2 3 4 5 6 |
gdf |
is the one-dimensional generative DF to be converted into a step-wise DF. |
xedges |
is a vector of observables x defining the edges of the bins for the step-wise DF. |
method |
specifies the interpolation method to be used. Choices are "constant", "linear" and "spline". In the latter two cases the generative distribution function is linearly extrapolated beyond the range of |
extrapolate |
is a logical flag. If |
dfswmodel
returns a list with two components gdf
and p.initial. The first component is a function of log-masses x
and a parameter vector p
. The second component is the initial parameter-vector producing a step-wise mass function that closely matches the Schechter function specified by p
.
Danail Obreschkow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # For an overall illustration run
dfexample(3)
# The follwoing is a step-by-step example.
# First, define and visulize a smooth Schechter function (a special type of galaxy mass function)
p.true = c(-2,11,-1.4) # Schechter function parameters
gdf = function(x) dfmodel(x, p.true, type='Schechter') # Schechter function
x = seq(5.8,12,0.01) # plotting range
plot(10^x, gdf(x), type='l', log='xy', ylim=c(1e-5,2))
# Define the edges of non-equal bins
xbin = c(6,7,7.5,seq(8,9,0.2),seq(9.5,11,0.5),11.8) # edges of bins
# Make and plot step-wise constant function
swconstant = dfswmodel(gdf, xbin, 'constant') # step-wise constant function
lines(10^x, swconstant$gdf(x, swconstant$p.initial), col='blue', lwd=3)
# Make and plot step-wise linear function
swlinear = dfswmodel(gdf, xbin, 'linear') # step-wise linear function
lines(10^x, swlinear$gdf(x, swlinear$p.initial), col='orange', lwd=2)
# Make and plot step-wise spline function
swspline = dfswmodel(gdf, xbin, 'spline') # step-wise linear function
lines(10^x, swspline$gdf(x, swspline$p.initial), col='red')
# Plot mid-points of bins
points(10^swconstant$xmid, 10^swconstant$p.initial, pch=20)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.