nodes: 0, module; 1, function_definition; 2, function_name:orth_chol; 3, parameters; 4, block; 5, identifier:order; 6, identifier:dist; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, dictionary_splat_pattern; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, if_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, expression_statement; 24, expression_statement; 25, expression_statement; 26, expression_statement; 27, for_statement; 28, expression_statement; 29, return_statement; 30, identifier:normed; 31, True; 32, identifier:sort; 33, string:"GR"; 34, identifier:cross_truncation; 35, float:1.; 36, identifier:kws; 37, comment:"""
      Create orthogonal polynomial expansion from Cholesky decomposition.
  
      Args:
          order (int):
              Order of polynomial expansion
          dist (Dist):
              Distribution space where polynomials are orthogonal
          normed (bool):
              If True orthonormal polynomials will be used instead of monic.
          sort (str):
              Ordering argument passed to poly.basis.  If custom basis is used,
              argument is ignored.
          cross_truncation (float):
              Use hyperbolic cross truncation scheme to reduce the number of
              terms in expansion.
  
      Examples:
          >>> Z = chaospy.Normal()
          >>> print(chaospy.around(chaospy.orth_chol(3, Z), 4))
          [1.0, q0, 0.7071q0^2-0.7071, 0.4082q0^3-1.2247q0]
      """; 38, assignment; 39, assignment; 40, assignment; 41, assignment; 42, assignment; 43, not_operator; 44, block; 45, assignment; 46, assignment; 47, assignment; 48, assignment; 49, assignment; 50, assignment; 51, assignment; 52, assignment; 53, assignment; 54, identifier:idx; 55, call; 56, block; 57, assignment; 58, identifier:polynomials; 59, identifier:dim; 60, call; 61, identifier:basis; 62, call; 63, identifier:length; 64, call; 65, identifier:cholmat; 66, call; 67, identifier:cholmat_inv; 68, attribute; 69, identifier:normed; 70, expression_statement; 71, expression_statement; 72, identifier:coefs; 73, call; 74, subscript; 75, identifier:cholmat_inv; 76, subscript; 77, integer:1; 78, subscript; 79, integer:0; 80, identifier:expected; 81, unary_operator; 82, subscript; 83, identifier:expected; 84, identifier:coefs; 85, attribute; 86, identifier:out; 87, dictionary; 88, subscript; 89, subscript; 90, identifier:range; 91, argument_list; 92, expression_statement; 93, expression_statement; 94, identifier:polynomials; 95, call; 96, identifier:len; 97, argument_list; 98, attribute; 99, argument_list; 100, identifier:len; 101, argument_list; 102, attribute; 103, argument_list; 104, call; 105, identifier:T; 106, assignment; 107, augmented_assignment; 108, attribute; 109, argument_list; 110, identifier:coefs; 111, slice; 112, slice; 113, identifier:coefs; 114, integer:0; 115, integer:0; 116, identifier:coefs; 117, integer:0; 118, slice; 119, call; 120, identifier:coefs; 121, slice; 122, integer:0; 123, identifier:coefs; 124, identifier:T; 125, identifier:out; 126, binary_operator:(0,)*dim; 127, identifier:coefs; 128, integer:0; 129, identifier:length; 130, assignment; 131, assignment; 132, attribute; 133, argument_list; 134, identifier:dist; 135, attribute; 136, identifier:basis; 137, keyword_argument; 138, keyword_argument; 139, keyword_argument; 140, keyword_argument; 141, keyword_argument; 142, identifier:basis; 143, attribute; 144, identifier:gill_king; 145, call; 146, attribute; 147, argument_list; 148, identifier:diag_mesh; 149, call; 150, identifier:cholmat_inv; 151, call; 152, identifier:numpy; 153, identifier:empty; 154, tuple; 155, integer:1; 156, integer:1; 157, integer:1; 158, attribute; 159, argument_list; 160, integer:1; 161, tuple; 162, identifier:dim; 163, identifier:index; 164, subscript; 165, subscript; 166, subscript; 167, attribute; 168, identifier:Poly; 169, identifier:out; 170, identifier:dim; 171, subscript; 172, identifier:float; 173, identifier:chaospy; 174, identifier:poly; 175, identifier:start; 176, integer:1; 177, identifier:stop; 178, identifier:order; 179, identifier:dim; 180, identifier:dim; 181, identifier:sort; 182, identifier:sort; 183, identifier:cross_truncation; 184, identifier:cross_truncation; 185, identifier:chaospy; 186, identifier:chol; 187, attribute; 188, argument_list; 189, attribute; 190, identifier:inv; 191, attribute; 192, attribute; 193, argument_list; 194, attribute; 195, argument_list; 196, binary_operator:length+1; 197, binary_operator:length+1; 198, identifier:numpy; 199, identifier:sum; 200, binary_operator:cholmat_inv*chaospy.descriptives.E(basis, dist, **kws); 201, unary_operator; 202, integer:0; 203, attribute; 204, integer:0; 205, identifier:out; 206, identifier:index; 207, identifier:coefs; 208, binary_operator:idx+1; 209, identifier:chaospy; 210, identifier:poly; 211, attribute; 212, slice; 213, attribute; 214, identifier:Cov; 215, identifier:basis; 216, identifier:dist; 217, identifier:numpy; 218, identifier:linalg; 219, identifier:cholmat; 220, identifier:T; 221, identifier:numpy; 222, identifier:repeat; 223, call; 224, call; 225, identifier:diag_mesh; 226, identifier:reshape; 227, attribute; 228, identifier:length; 229, integer:1; 230, identifier:length; 231, integer:1; 232, identifier:cholmat_inv; 233, call; 234, integer:1; 235, subscript; 236, identifier:keys; 237, identifier:idx; 238, integer:1; 239, identifier:coefs; 240, identifier:shape; 241, integer:1; 242, identifier:chaospy; 243, identifier:descriptives; 244, attribute; 245, argument_list; 246, identifier:len; 247, argument_list; 248, identifier:cholmat_inv; 249, identifier:shape; 250, attribute; 251, argument_list; 252, identifier:basis; 253, identifier:idx; 254, identifier:numpy; 255, identifier:diag; 256, identifier:cholmat_inv; 257, identifier:cholmat_inv; 258, attribute; 259, identifier:E; 260, identifier:basis; 261, identifier:dist; 262, dictionary_splat; 263, identifier:chaospy; 264, identifier:descriptives; 265, identifier:kws
code: def orth_chol(order, dist, normed=True, sort="GR", cross_truncation=1., **kws):
      """
      Create orthogonal polynomial expansion from Cholesky decomposition.
  
      Args:
          order (int):
              Order of polynomial expansion
          dist (Dist):
              Distribution space where polynomials are orthogonal
          normed (bool):
              If True orthonormal polynomials will be used instead of monic.
          sort (str):
              Ordering argument passed to poly.basis.  If custom basis is used,
              argument is ignored.
          cross_truncation (float):
              Use hyperbolic cross truncation scheme to reduce the number of
              terms in expansion.
  
      Examples:
          >>> Z = chaospy.Normal()
          >>> print(chaospy.around(chaospy.orth_chol(3, Z), 4))
          [1.0, q0, 0.7071q0^2-0.7071, 0.4082q0^3-1.2247q0]
      """
      dim = len(dist)
      basis = chaospy.poly.basis(
          start=1, stop=order, dim=dim, sort=sort,
          cross_truncation=cross_truncation,
      )
      length = len(basis)
  
      cholmat = chaospy.chol.gill_king(chaospy.descriptives.Cov(basis, dist))
      cholmat_inv = numpy.linalg.inv(cholmat.T).T
      if not normed:
          diag_mesh = numpy.repeat(numpy.diag(cholmat_inv), len(cholmat_inv))
          cholmat_inv /= diag_mesh.reshape(cholmat_inv.shape)
  
      coefs = numpy.empty((length+1, length+1))
  
      coefs[1:, 1:] = cholmat_inv
      coefs[0, 0] = 1
      coefs[0, 1:] = 0
  
      expected = -numpy.sum(
          cholmat_inv*chaospy.descriptives.E(basis, dist, **kws), -1)
      coefs[1:, 0] = expected
  
      coefs = coefs.T
  
      out = {}
      out[(0,)*dim] = coefs[0]
      for idx in range(length):
          index = basis[idx].keys[0]
          out[index] = coefs[idx+1]
  
      polynomials = chaospy.poly.Poly(out, dim, coefs.shape[1:], float)
  
      return polynomials