Newer
Older
Master_thesis / thesis / spaces.tex
  1. \subsection{Spaces and Dimensions}
  2. \label{sec:spaces and dimensions}
  3.  
  4. The extension to more than one dimension when fitting a model contains some
  5. ambiguities. The data, limits and the models all have corresponding axes or
  6. columns that should match.
  7. To deal with that in a simple, yet consistent manner, \zfit{} has a \zspace{}.
  8. The
  9. responsibility of this class is to define and handle the axes or dimensions and
  10. limits. To
  11. understand the concept and the \zspace{} itself, three definitions need to be
  12. made:
  13.  
  14. \begin{description}
  15. \item[Observables] The observables are the
  16. \textit{named axes of a coordinate system}. A single observable is a string
  17. and a list of strings acts as several observables describing a higher
  18. dimensional system. In the context of data this is equivalent
  19. to columns in a data frame. Observables allow a named, \textit{inter-object}
  20. identification of axes. Therefore, working with observables allows to work
  21. independently of the underlying data ordering.
  22. \item[Axes] Axes are integers and are used to \textit{enumerate the axes
  23. of a coordinate system}. This corresponds to indices of an array and
  24. provides the fully order-based mapping necessary for \textit{intra-object}
  25. manipulations. For example, a \zdata{} with three
  26. columns has three axes, 0, 1, and 2, which can though be reordered so that
  27. the corresponding observables match the order of some other observables.
  28. \item[Limits] A description of boundaries that can be used to define any
  29. kind of limits of the axes. Currently only rectangular limits are supported
  30. but arbitrary shaped limits will be provided in the future.
  31. \end{description}
  32.  
  33. A \zspace{} can be initialized with observables and limits to define a domain.
  34. When
  35. it's assigned to an object, it automatically connects the axes of the object
  36. with the observables from the \zspace{}. More details on the implementation and
  37. use cases as well as additional functionality for dimensional handling can be
  38. found in Appendix \ref{appendix:spaces defined}.
  39.  
  40. \subsubsection{Limits}
  41. \label{sec:multiple limits}
  42.  
  43. Limits are used in many instances, be it in sampling limits, integration or
  44. data limits. A \zspace{} not only defines the observables but typically also
  45. has limits associated with it.
  46. In one-dimensional fits, limits as seen in the
  47. example in Sec. \ref{sec:quickstart}
  48. are needed. Simple limits consist of a tuple for each observable with lower and
  49. upper limits. For example a \zspace{} in one observable \texttt{x} from $-5$ to
  50. $3$ can be created like
  51.  
  52. \begin{center}
  53. \begin{minipage}{\textwidth}
  54. \begin{python}
  55. limits = zfit.Space(obs="x", limits=(-5, 3))
  56. \end{python}
  57. \end{minipage}
  58. \end{center}
  59.  
  60. This is the simplest way of specifying limits and rather a special case. For
  61. anything more sophisticated, such as multiple limits or multiple observables,
  62. either a composition of \zspace s or the more
  63. general format as explained in Appendix
  64. \ref{appendix:general limits} has to be used. For example when blinding a
  65. region, a \zspace{}
  66. with
  67. multiple limits can be used.
  68.  
  69. While the general format is fully specified independent of a \zspace{} and can
  70. therefore be useful programmatically, a \zspace{} with multiple limits can be
  71. built
  72. unambiguously from \zspace s with simple limits by adding them, either through
  73. a dedicated \zfit{} function or using the addition operator in Python. In
  74. this way, multiple limits can be created through simple composition and without
  75. the need of using the more general format.
  76.  
  77. As an example, let's assume a \zspace{} should be created with the observables
  78. \texttt{x, y} in the two domains $l_01$ and $l_23$
  79. \begin{align*}
  80. l_01 &= \{(x, y) | x_0 < x < x_1, y_0 < y < y_1\} \\
  81. l_23 &= \{(x, y) | x_2 < x < x_3, y_2 < y < y_3\}.
  82. \end{align*}
  83.  
  84. We start out creating the domains by specifying the limits in the \textit{x}
  85. observable
  86.  
  87. \begin{center}
  88. \begin{minipage}{\textwidth}
  89. \begin{python}
  90. limit_x_01 = zfit.Space(obs="x", limits=(x0, x1))
  91. limit_x_23 = zfit.Space(obs="x", limits=(x2, x3))
  92. limits_x = limit_x_01 + limit_x_23
  93. \end{python}
  94. \end{minipage}
  95. \end{center}
  96.  
  97. Equivalently \pyth{limits_y} can be composed. Since going to higher dimensions
  98. is unambiguous with two limits in each space, this can be done using the
  99. multiplication operator in Python or the function
  100. \pyth{combine}.\footnote{If a different number of limits were defined, an error
  101. would be thrown.}
  102.  
  103. \begin{center}
  104. \begin{minipage}{\textwidth}
  105. \begin{python}
  106. limits_xy = limits_x * limits_y
  107. limits_yx = limits_y * limits_x
  108. \end{python}
  109. \end{minipage}
  110. \end{center}
  111.  
  112. The difference between \pyth{limits_xy} and \pyth{limits_yx} is the order of
  113. the observables. In the first case, it's \pyth{["x", "y"]} while for the latter
  114. it's \pyth{["y", "x"]}. In order to ensure consistency, if the two \zspace s
  115. already have observables in common, the limits in this observables have to be
  116. the same. \footnote{This exact behaviour
  117. of the multiplication and observables is the same if models are multiplied.}
  118. Reordering the \zspace{} is possible as well as extracting a subspace, a
  119. \zspace{} only defined in subset of the dimensions. More details can be found
  120. in Appendix \ref{appendix:spaces defined}.