Joint distribution of values from pmf1 and pmf2.

    Args:
        pmf1: Pmf object
        pmf2: Pmf object

    Returns:
        Joint pmf of value pairs
490262
def MakeJoint(pmf1, pmf2):
    
    joint = Joint()
    for v1, p1 in pmf1.Items():
        for v2, p2 in pmf2.Items():
            joint.Set((v1, v2), p1 * p2)
    return joint
252306
private void fswap(int[] fmap, int zz1, int zz2) {
        int zztmp = fmap[zz1];
        fmap[zz1] = fmap[zz2];
        fmap[zz2] = zztmp;
    }
510539
function pdf(x, df1, df2) {
    var p, q, f;

    if (x < 0)
      return 0;

    if (df1 <= 2) {
      if (x === 0 && df1 < 2) {
        return Infinity;
      }
      if (x === 0 && df1 === 2) {
        return 1;
      }
      return (1 / jStat.betafn(df1 / 2, df2 / 2)) *
              Math.pow(df1 / df2, df1 / 2) *
              Math.pow(x, (df1/2) - 1) *
              Math.pow((1 + (df1 / df2) * x), -(df1 + df2) / 2);
    }

    p = (df1 * x) / (df2 + x * df1);
    q = df2 / (df2 + x * df1);
    f = df1 * q / 2.0;
    return f * jStat.binomial.pdf((df1 - 2) / 2, (df1 + df2 - 2) / 2, p);
  }
1141612
def MakePmf(self, xs, name=''):
        
        pmf = Pmf(name=name)
        for x in xs:
            pmf.Set(x, self.Density(x))
        pmf.Normalize()
        return pmf
1260744
def _initialise_pmf(self):
        """"""
        # Easy vars
        epsilon = self.epsilon
        alpha = self.alpha
        preds = self.predictions
        p1 = self._probs_avg_opt_class
        p0 = 1 - p1
        n_items = self._n_items
        F = self._F_guess

        # Calculate optimal instrumental pmf
        sqrt_arg = np.sum(preds * (alpha**2 * F**2 * p0 + (1 - F)**2 * p1) + \
                          (1 - preds) * (1 - alpha)**2 * F**2 * p1, \
                          axis=1) #: sum is over classifiers
        self._inst_pmf = np.sqrt(sqrt_arg)
        # Normalize
        self._inst_pmf /= np.sum(self._inst_pmf)
        # Epsilon-greedy: (1 - epsilon) q + epsilon * p
        self._inst_pmf *= (1 - epsilon)
        self._inst_pmf += epsilon * 1/n_items
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)
134764
def _union_copy(dict1, dict2):
    

    for key, value in dict2.items():
        if key in dict1 and isinstance(value, dict):
            dict1[key] = _union_copy(dict1[key], value)
        else:
            dict1[key] = copy.deepcopy(value)
    return dict1
941806
def ssd(p1, p2):
    
    return 2 - np.sum([(a-b)**2 for a,b in zip(p1,p2)])
318430
public static double computeCorrelation(final List<Double> list1, final List<Double> list2)
    {
        final SpearmansRankCorrelation_old src = new SpearmansRankCorrelation_old();
        for (int i = 0; i < list1.size(); i++) {
            src.addXValue(Integer.toString(i), list1.get(i));
            src.addYValue(Integer.toString(i), list2.get(i));
            i++;
        }
        return src.calculate();
    }
911238
def subject_pair_simj(subject1, subject2, **kwargs):
    
    i, u = subject_pair_overlap(subject1, subject2, **kwargs)
    if i==0:
        return 0.0
    return i / u
858716
def divide(x1, x2, output_shape=None, name=None):
  
  output_shape = convert_to_shape(output_shape)
  if not isinstance(x2, Tensor):
    return ScalarMultiplyOperation(x1, 1.0 / x2).outputs[0]
  with tf.name_scope(name, default_name="divide"):
    x1, x2 = binary_arguments_to_tensors(x1, x2)
    return multiply(x1, reciprocal(x2), output_shape=output_shape)
870137
def corrdfs(df1,df2,method):
    
    dcorr=pd.DataFrame(columns=df1.columns,index=df2.columns)
    dpval=pd.DataFrame(columns=df1.columns,index=df2.columns)
    for c1 in df1:
        for c2 in df2:
            if method=='spearman':
                dcorr.loc[c2,c1],dpval.loc[c2,c1]=spearmanr(df1[c1],df2[c2],
                                                        nan_policy='omit'
                                                       )
            elif method=='pearson':
                dcorr.loc[c2,c1],dpval.loc[c2,c1]=pearsonr(df1[c1],df2[c2],
#                                                         nan_policy='omit'
                                                       )
                
    if not df1.columns.name is None:
        dcorr.columns.name=df1.columns.name
        dpval.columns.name=df1.columns.name
    if not df2.columns.name is None:
        dcorr.index.name=df2.columns.name
        dpval.index.name=df2.columns.name
    return dcorr,dpval
145848
def two_gaussian(freq, freq0_1, freq0_2, sigma1, sigma2, amp1, amp2,
                   offset, drift):
   
   return (gaussian(freq, freq0_1, sigma1, amp1, offset, drift) +
           gaussian(freq, freq0_2, sigma2, amp2, offset, drift))
910827
public function pmf(): float
    {
        $a = $this->a;
        $b = $this->b;

        $n = $b - $a + 1;

        return 1 / $n;
    }
109209
def posterior_covariance_between_points(self, X1, X2):
        
        return self.posterior.covariance_between_points(self.kern, self.X, X1, X2)
717088
def vector(p1, p2):
    
    return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in range(len(p1))])
130702
def hcf(num1, num2):
    

    if num1 > num2:
        smaller = num2
    else:
        smaller = num1
    for i in range(1, smaller + 1):
        if ((num1 % i == 0) and (num2 % i == 0)):
            return i