One to one constructor for mapping some shape of k to
    a matching shaped ChiSquared.
    
    :param k: the number of degrees of freedom
429068
def ChiSquared(k: vertex_constructor_param_types, label: Optional[str]=None) -> Vertex:
    
    return Double(context.jvm_view().ChiSquaredVertex, label, cast_to_integer_vertex(k))
972430
def _chimera_neighbors(M, N, L, q):
    ""
    (x, y, u, k) = q
    n = [(x, y, 1 - u, l) for l in range(L)]
    if u == 0:
        if x:
            n.append((x - 1, y, u, k))
        if x < M - 1:
            n.append((x + 1, y, u, k))
    else:
        if y:
            n.append((x, y - 1, u, k))
        if y < N - 1:
            n.append((x, y + 1, u, k))
    return n
683347
def K(self, parm):
        
        return OU_K_matrix(self.X, parm) + np.identity(self.X.shape[0])*(10**-10)
57383
public float[] t1(float[] z, int k) {
    float[] result = new float[z.length];
    float[] w = new float[z.length];

    for (int i = 0; i < w.length; i++) {
      w[i] = (float) 1.0;
    }

    for (int i = 0; i < z.length - 1; i++) {
      int head = i + 1;
      int tail = z.length - 1;
      float[] subZ = subVector(z, head, tail);
      float[] subW = subVector(w, head, tail);
      float aux = (new Transformations()).rSum(subZ, subW);
      result[i] = (new Transformations())
        .bParam(z[i], aux, (float) 0.98 / (float) 49.98, (float) 0.02, (float) 50);
    }

    result[z.length - 1] = z[z.length - 1];
    return result;
  }
1301257
def Qk(self, k):
        
        return self.Q[:, :, self.index[self.Q_time_var_index, k]]
77777
def _setup_xy(self,bounds,xdensity,ydensity,x,y,orientation):
        
        self.debug("bounds=%s, xdensity=%s, ydensity=%s, x=%s, y=%s, orientation=%s",bounds,xdensity,ydensity,x,y,orientation)
        # Generate vectors representing coordinates at which the pattern
        # will be sampled.

        # CB: note to myself - use slice_._scs if supplied?
        x_points,y_points = SheetCoordinateSystem(bounds,xdensity,ydensity).sheetcoordinates_of_matrixidx()

        # Generate matrices of x and y sheet coordinates at which to
        # sample pattern, at the correct orientation
        self.pattern_x, self.pattern_y = self._create_and_rotate_coordinate_arrays(x_points-x,y_points-y,orientation)
1192592
def ks_distance(a, b):
    ''''''
    if len(a.shape) == 1:
        return np.max(np.abs(a.cumsum() - b.cumsum()))
    return np.max(np.abs(a.cumsum(axis=1) - b.cumsum(axis=1)), axis=1)
702712
def solve_kkt(U_Q, d, G, A, U_S, rx, rs, rz, ry, dbg=False):
    
    nineq, nz, neq, _ = get_sizes(G, A)

    invQ_rx = torch.potrs(rx.view(-1, 1), U_Q).view(-1)
    if neq > 0:
        h = torch.cat([torch.mv(A, invQ_rx) - ry,
                       torch.mv(G, invQ_rx) + rs / d - rz], 0)
    else:
        h = torch.mv(G, invQ_rx) + rs / d - rz

    w = -torch.potrs(h.view(-1, 1), U_S).view(-1)

    g1 = -rx - torch.mv(G.t(), w[neq:])
    if neq > 0:
        g1 -= torch.mv(A.t(), w[:neq])
    g2 = -rs - w[neq:]

    dx = torch.potrs(g1.view(-1, 1), U_Q).view(-1)
    ds = g2 / d
    dz = w[neq:]
    dy = w[:neq] if neq > 0 else None

    # if np.all(np.array([x.norm() for x in [rx, rs, rz, ry]]) != 0):
    if dbg:
        import IPython
        import sys
        IPython.embed()
        sys.exit(-1)

    # if rs.norm() > 0: import IPython, sys; IPython.embed(); sys.exit(-1)
    return dx, ds, dz, dy
770272
def shape(self):
        ""
        keys = self.keys()
        if self.ndims == 1:
            return (len(keys), 1)
        return len(set(k[0] for k in keys)), len(set(k[1] for k in keys))
297166
def nmap(a, b, c, d, curvefn=None, normfn=None):
    
    if not curvefn:
        curvefn = lambda x: x

    def map(n):
        r = 1.0 * (n - a) / (b - a)
        out = curvefn(r) * (d - c) + c
        if not normfn:
            return out
        return normfn(out)
    return map
218408
def kld(d1, d2):
    
    d1, d2 = flatten(d1), flatten(d2)
    return entropy(d1, d2, 2.0)
214360
public float[] t1(float[] z, int k) {
    float[] result = new float[z.length];

    for (int i = 0; i < z.length; i++) {
      result[i] = (new Transformations()).sDecept(z[i], (float) 0.35, (float) 0.001, (float) 0.05);
    }

    return result;
  }
31198
def _guess_x_kmeans(self, y_desired, **kwargs):
        """"""
        k = kwargs.get('k', self.k)
        _, indexes = self.fmodel.dataset.nn_y(y_desired, k=k)
        X = np.array([self.fmodel.get_x(i) for i in indexes])
        if np.sum(X) == 0.:
            centroids = [self.fmodel.get_x(indexes[0])]
        else:
            try:
                centroids, _ = kmeans2(X, 2)
            except np.linalg.linalg.LinAlgError:
                centroids = [self.fmodel.get_x(indexes[0])]
        return centroids
903761
def select_k_best(self, k):
        
        x_new = SelectKBest(chi2, k=k).fit_transform(self.x_train, self.y_train)
        return x_new
486570
def Kdiag(self,X,target):
        """"""
        foo = np.zeros((X.shape[0],X.shape[0]))
        self.K(X,X,foo)
        target += np.diag(foo)
1115848
def polyder(c, m=1, scl=1, axis=0):
    '''
    '''
    c = list(c)
    cnt = int(m)

    if cnt == 0:
        return c

    n = len(c)
    if cnt >= n:
        c = c[:1]*0
    else:
        for i in range(cnt):
            n = n - 1
            c *= scl
            der = [0.0 for _ in range(n)]
            for j in range(n, 0, -1):
                der[j - 1] = j*c[j]
            c = der
    return c
1275162
def _kp2(A, B):
    
    N = A.shape[0]
    if B.shape[0] != N:
        raise(ValueError)
    newshape1 = A.shape[1]*B.shape[1]
    return np.einsum('ijk,ilm->ijlkm', A, B).reshape(N, newshape1, -1)