code: def from_simplex(x):
      r
      n = x.shape[-1]
      # z are the stick breaking fractions in [0,1]
      # the last one is always 1, so don't worry about it
      z = np.empty(shape=x.shape)
      z[..., 0] = x[..., 0]
      z[..., 1:-1] = x[..., 1:-1] / (1 - x[..., :-2].cumsum(axis=-1))
  
      # now z are the logit-transformed breaking fractions
      z[..., :-1] = logit(z[..., :-1]) - logit(1 / (n - np.arange(n-1, dtype=np.float)))
      # set this to 0 manually to avoid subtracting inf-inf
      z[..., -1] = 0
      return z
docs: r"""
      Inteprets the last index of x as unit simplices and returns a
      real array of the sampe shape in logit space.
  
      Inverse to :func:`to_simplex` ; see that function for more details.
  
      :param np.ndarray: Array of unit simplices along the last index.
      
      :rtype: ``np.ndarray``