Find Kth Smallest Element in Two Sorted Arrays

Problem Given K and two sorted arrays with length M and N, find the K-th smallest element among all elements in the two arrays.   Code import sys class Solution(object): def findKthSmallest(self, nums1, nums2, k): “”” :type nums1: sorted List[int] :type nusm2: sorted List[int] :type k: int :rtype: int “”” if not (0 <k <= …

Solve Travelling Salesman Problem using DP

Claim In this post, I am using the same notation as in the video below and the wiki page (https://en.wikipedia.org/wiki/Held%E2%80%93Karp_algorithm)   Our problem is given a matrix costs in which costs[i][j] is the traveling cost going from node i to node j, we are asked to return the minimum cost for traveling from node 0 and visit …

You are almost always getting significant p-value in large dataset

Recently, an exploding reproducibility research paper [1] shows that more than half of past published papers in the main psychological journals can’t be replicated to generate significance findings. This makes me dig a little further on how to conduct statistical tests. Let me show you my little experiments in `R` first. # remove(list=ls()) set.seed(19910715) n1 …

Minimum Description Length (MDL): a scoring function to learn Bayesian Network Structure

Bayesian Network Augmented Naive-Bayes (BAN) is an improved version of Naive-Bayes, in which every attribute $latex X_i$ may have at most one other attribute as its parent other than the class variable $latex C$. For example (figure from [1]): Though BAN provides a more flexible structure compared to Naive Bayes, the structure (i.e., dependence/independence relationships …

Collection of statistical hypothesis tests

This post is a collection of hypothesis test methodologies. The full collection is listed here: http://www.biostathandbook.com/testchoice.html. My post just goes over several hypothesis tests that are relevant to my research.   One-way ANOVA: http://www.biostathandbook.com/onewayanova.html If you have one measurement variable and one nominal variable, and the nominal variable separates subjects into multiple groups, you want to test  …