code: def alpha_aligned(
      returns,
      factor_returns,
      risk_free=0.0,
      period=DAILY,
      annualization=None,
      _beta=None,
  ):
      """Calculates annualized alpha.
  
      If they are pd.Series, expects returns and factor_returns have already
      been aligned on their labels.  If np.ndarray, these arguments should have
      the same shape.
  
      Parameters
      ----------
      returns : pd.Series or np.ndarray
          Daily returns of the strategy, noncumulative.
          - See full explanation in :func:`~empyrical.stats.cum_returns`.
      factor_returns : pd.Series or np.ndarray
           Daily noncumulative returns of the factor to which beta is
           computed. Usually a benchmark such as the market.
           - This is in the same style as returns.
      risk_free : int, float, optional
          Constant risk-free return throughout the period. For example, the
          interest rate on a three month us treasury bill.
      period : str, optional
          Defines the periodicity of the 'returns' data for purposes of
          annualizing. Value ignored if `annualization` parameter is specified.
          Defaults are:
              'monthly':12
              'weekly': 52
              'daily': 252
      annualization : int, optional
          Used to suppress default values available in `period` to convert
          returns into annual returns. Value should be the annual frequency of
          `returns`.
          - See full explanation in :func:`~empyrical.stats.annual_return`.
      _beta : float, optional
          The beta for the given inputs, if already known. Will be calculated
          internally if not provided.
  
      Returns
      -------
      float
          Alpha.
      """
      if len(returns) < 2:
          return np.nan
  
      ann_factor = annualization_factor(period, annualization)
  
      if _beta is None:
          _beta = beta_aligned(returns, factor_returns, risk_free)
  
      adj_returns = _adjust_returns(returns, risk_free)
      adj_factor_returns = _adjust_returns(factor_returns, risk_free)
      alpha_series = adj_returns - (_beta * adj_factor_returns)
  
      return nanmean(alpha_series) * ann_factor
  
imports: from __future__ import division
  from functools import wraps
  import pandas
  import numpy
  from scipy import stats
  from six import iteritems
  from empyrical.utils import nanmean, nanstd, nanmin
label_desc: Use image node_id 21 for calling a global function with example usage: alpha_aligned(returns, factor_returns, risk_free, period, annualization, _beta) and returns: unknown, np