<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bu Yifan on Medium]]></title>
        <description><![CDATA[Stories by Bu Yifan on Medium]]></description>
        <link>https://medium.com/@marvinbu?source=rss-b2ab1a907d41------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uS4Oh8pXR3zpPhAFJMY9hA@2x.jpeg</url>
            <title>Stories by Bu Yifan on Medium</title>
            <link>https://medium.com/@marvinbu?source=rss-b2ab1a907d41------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:22:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marvinbu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Machine Learning — K-Nearest Neighbors(K-NN)]]></title>
            <link>https://marvinbu.medium.com/machine-learning-k-nearest-neighbors-k-nn-778f445f5a48?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/778f445f5a48</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[knn-algorithm]]></category>
            <category><![CDATA[knn]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Mon, 23 Nov 2020 17:09:42 GMT</pubDate>
            <atom:updated>2020-11-23T17:09:42.411Z</atom:updated>
            <content:encoded><![CDATA[<h3>Machine Learning — K-Nearest Neighbors(K-NN)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*WizIHb2NgR_-K1NXIUjnlA.png" /><figcaption>Statistic How To (2019)</figcaption></figure><ol><li><strong>Definition</strong></li></ol><p>The <strong>K-Nearest Neighbors (K-NN)</strong> algorithm is one of the most fundamental and simple classification scheme which can be used for both classification and regression problems. However, the algorithm is mostly used for classification predictive problems in industry. ‘Feature similarity’ is used to predict the values of new data points which we wish to classify. The ‘feature similarity’ suggests that the new data point will be assigned a value which depends on the ‘closeness’ of it with the data points in the training set.</p><p>2. <strong>The Algorithm</strong></p><p>Suppose now we have a dataset, we would like to implement K-NN algorithm, we have already known that the algorithm depends on the ‘closeness’ of the test sample and the specified training samples, thus, we should find a way to measure the distance between them. There are several distance metrics could be used to calculate the distance, the most commonly used method is called Euclidean distance. The function is defined as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGLikR6HdwjQCuYPGoiraA.png" /></figure><p>Other distance measure functions includes the Manhattan and the Minkowski.</p><p>After we calculated the distance between the new data point and all other points, we could sort the distance values in ascending order. If we take the first row from the top which is the smallest distance value, that will be 1-Nearest Neighbor, then we will classify the new data point in the same category as its ‘neareast neighbor’.</p><p>Instead of taking one value, we can extend the idea to a K-NN rule by taking the first K (K can be any integer) rows from the sorted array. Then, we will classify the new data point based on the majority of the K-NN votes in the list.</p><p>The choice of K is somewhat arbitrary, however, K can be adjusted based on the size of the dataset and the accuracy of predicting. Some experimentation of different value of K is needed in order to get the best value of K which could minimize the misclassification rate in the validation data. If the value of K is too small, the new data point which we need to classify will be very sensitive to the classification of the closest. A larger value of K will reduce the variability, however, if the value of K is too large, it will induce bias into the classification decisions. Usually, the value of K we use will be between 1 and 20.</p><p>To sum it up, In order to implement K-NN algorithm, we could follow the steps below:</p><ul><li>First, we got our dataset, load the train data and test data.</li><li>Choose a specified value of K, then for each data point in the test data, we measure the distance between the point and all other data points in train data.</li><li>Based on the distance values and the value of K which we chose, we classify the new data point based on the majority of the votes in the list.</li><li>Check the predicting accruacy of different values of K, then we pick the K with highest accruacy.</li></ul><p>3. <strong>Example</strong></p><p>Now let us implement the K-NN algorithm on the dataset in Python. The Iris dataset is used in this case.</p><p>The Iris dataset could be download here: <a href="https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data">https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data</a></p><p>We first take a look at the dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-LnuvLvtrP1q_RecrJIHow.png" /></figure><p>The dataset has four features (X) and the column ‘Class’ is our y.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VnWPH2n3yCepApGtXltThg.png" /></figure><p>The next step we need to normalize the data, this procedure is important in order to ensure that equal weight are given to each variable. Then we split the data into train set and test set with the help of ‘train_test_split’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0_0ruA4k_u3lVhZtj_7Cg.png" /></figure><p>After the preparation is done, we could implement the algorithm, we will make the value of K equal to 4 first to get the model, and we will also calculate the accruacy in this case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e4fjVpOnyAlGXmvoPrunrA.png" /></figure><p>For the value of K equals to 4, the K-NN gives us 91.67% accuracy for the test set. The predicting result is not bad, let us see how the other values of K performs. We would range the value of K from 1 to 9.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVPzxbLqanIPDSjYAeTLAg.png" /></figure><p>As we can see, when the value of K equls to 8, the K-NN gives us the highest accuracy for the test set of 98.33%.</p><p><strong>Reference</strong></p><p>Evans, J. (2017) Business Analytics. England: Pearson.</p><p>Madhu Sanjeevi (2017) ‘Chapter 5 : K-nearest neighbors algorithm with code from scratch.’</p><p>Tutorialspoint (2020) ‘<em>KNN Algorithm — Finding Nearest Neighbors</em>’. <a href="https://www.tutorialspoint.com/machine_learning_with_python/machine_learning_with_python_knn_algorithm_finding_nearest_neighbors.htm">https://www.tutorialspoint.com/machine_learning_with_python/machine_learning_with_python_knn_algorithm_finding_nearest_neighbors.htm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=778f445f5a48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistics — Statistical Sampling and Sampling Distributions]]></title>
            <link>https://marvinbu.medium.com/statistics-statistical-sampling-and-sampling-distributions-bd1777f24492?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd1777f24492</guid>
            <category><![CDATA[sampling]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[sampling-methods]]></category>
            <category><![CDATA[sampling-distribution]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Sun, 08 Nov 2020 15:54:16 GMT</pubDate>
            <atom:updated>2020-11-08T15:54:16.879Z</atom:updated>
            <content:encoded><![CDATA[<h3>Statistics — Statistical Sampling and Sampling Distributions</h3><p><strong>Statistical Sampling</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*SXWb7395em5LCHSn8YrsbQ.jpeg" /><figcaption>Verdict Foodservice (2019)</figcaption></figure><ol><li><strong>Population &amp; Sample</strong></li></ol><p>As in this article we are going to talk about statistical sampling, the first thing we should know is the difference between a population and a sample. Suppose we want to investigate the average share of income do households in U.K. spend in restaurants. Our population in this case will be all households currently located in U.K., theoretically speaking, we could knock each door of the households and get the answer. However, in this way, it would be costly and time-consuming to implement and aggregate all the answers. Instead, we could first get a sample of 100 households, then generalize our results from the sample to the population.</p><p>We now take a look at the definitions:</p><blockquote>‘A <strong>population </strong>consists of all items of interest for a particular decision or investigation.’</blockquote><blockquote>‘A <strong>sample</strong> is a subset of a population.’</blockquote><blockquote>‘Sampling is the foundation of statistical analysis. We use sample data in business analytics applications for many purposes.’ Such as estimating the mean, variance, or proportion of a very large or unknown population, providing values for inputs in decision models and understanding customer satisfaction etc.</blockquote><p>2. <strong>Sampling Methods</strong></p><p>There are many choices of sampling methods exist. In order to draw valid conclusion from our results, we should determine which sampling method to use. Basically, sampling methods can be categorized into two types: <strong>probability sampling</strong> and <strong>non-probability sampling</strong>. Probability sampling involves selecting the items using some random procedure, thus, probability sampling allows us to draw valid statistical conclusions about the population. Non-probability sampling involves non-random procedure based on judgement or convenience. The method of sampling we select is crucial for the whole sampling process, below are the lists of some common sampling methods that we usually use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euWbgJWH50DDpRdA4pLpCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujH-EQRdd5KKuxuhrhVuSQ.png" /></figure><p><strong>Sampling Distributions</strong></p><ol><li><strong>Estimators</strong></li></ol><p>An estimator is a statistic used to estimate some fact about the population, in other words, an estimator could be regarded as the rule that creates an estimate. Thus, an estimate is the value of the estimator using a specific sample. Recall the example we used in first section, we want to investigate the average share of income do households in U.K. spend in restaurants. Suppose now we got a sample of 100 households from the population.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzWkl9yzgVuk3-WQmCFQ3w.png" /></figure><p>Also, we could also use the sample variance to estimate a population variance, and the sample proportion to estimate a population proportion.</p><p>2. <strong>Sampling Error</strong></p><p>When we randomly took a sample from a population, the value of statistics computed by analyzing the sample, i.e. estimates of a population parameters, will differ from the value of statistics computed by analyzing the entire population to some extent. Sampling error occurs because samples are only a subset of the population. Although sampling error could be minimized, it could not be totally avoided.</p><p>Another type of error is called non-sampling error, non-sampling error occurs while the sample took could not represent the target population adequately. For example, poor sampling design or targetting the wrong population frame would cause non-sampling errors. There are many types of non-sampling errors and the names used might differ.</p><blockquote>‘To draw good conclusions from samples, analysts need to eliminate non-sampling error and understand the nature of the sampling error.’</blockquote><p>3. <strong>Sampling Distributions</strong></p><p>Now we can consider our example, we want to investigate the average share of income do households in U.K. spend in restaurants.</p><ul><li>We set the sample size to 100 households.</li><li>Then we take repeated samples of the size 100 from the population, for each samples we calculate the sample mean and record the result.</li><li>At last, we plot a histogram of the sample means.</li></ul><p>Following above steps, we could get the sampling distribution of the sample mean. Thus, we would give a definition to sampling distribution:</p><blockquote>‘A sampling distribution is a probability distribution of statistic (such as the mean) that results from selecting an infinite number of random samples of the same size from a population.’</blockquote><p>Note that the sampling distributions are theoretical, instead of selecting an infinite number of random samples, we would conduct repeated sampling, and use the <strong>central limit theorem</strong> to build the sampling distribution.</p><blockquote>‘The central limit theorem states that if the sample size is large enough, the sampling distribution of the mean is approximately normally distributed, regardless of the distribution of the population and that the mean of the sampling distribution will be the same as that of the population.</blockquote><p>Another key result about the sampling distribution of the mean that statistians found is the standard deviation of the sampling distribution of the mean, also called the <strong>standard error of the mean</strong>. Here is the function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHUwRMlfJT9M1g5yYD0feg.png" /></figure><p>From the function, we could see that as <em>n</em> increases, the value of the standard error of the mean will decrease. This suggests that if we take larger sample sizes, we will have less sampling error, in other words, the variance of the sampling distribution goes down. In our example, instead of setting the sample size as 100, we will set the sample size to 300. The conclusion is more intuitional if we plot different sample sizes in graphs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfNLp4rwd7A2ad-I4CxIfg.png" /><figcaption>— ‘Estimation’ [PowerPoint presentation] Grigorios Emvalomatis</figcaption></figure><p><strong>Reference</strong></p><p>Emvalomatis, G. (2020) ‘Estimation’ [PowerPoint presentation]. <em>BU52018: Business Analytics</em>.</p><p>McCombes, S. (2019). <em>An introduction to sampling methods. </em>scribbr. <a href="https://www.scribbr.com/methodology/sampling-methods/">https://www.scribbr.com/methodology/sampling-methods/</a></p><p>McLeod, S. A. (2019). <em>Sampling distribution</em>. Simply Psychology. <a href="https://www.simplypsychology.org/sampling-distribution.html">https://www.simplypsychology.org/sampling-distribution.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd1777f24492" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistic — Distributions of Discrete random variables]]></title>
            <link>https://marvinbu.medium.com/statistic-distributions-of-discrete-random-variables-fdce46584633?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdce46584633</guid>
            <category><![CDATA[poisson-distribution]]></category>
            <category><![CDATA[binomial-distribution]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[bernoulli-distribution]]></category>
            <category><![CDATA[discrete-random-variable]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Thu, 29 Oct 2020 13:40:47 GMT</pubDate>
            <atom:updated>2020-11-08T15:56:07.390Z</atom:updated>
            <content:encoded><![CDATA[<h3>Statistics — Distributions of Discrete random variables</h3><p>In this article, we would like to introduce three main kinds of distributions of discrete random variables, these are the Bernoulli distribution, the Binomial distribution and the Poisson distribution. We will give each definitions, examples and also the basic properties of the distributions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*yCJsy59fpG-m6WBgv5UfZw.png" /><figcaption>— wikiHow</figcaption></figure><p><strong>1. Bernoulli Distribution</strong></p><p>1.1. <strong>Definition</strong></p><p>A <strong>Bernoulli distribution</strong> models a single trail of flipping a ‘fair’ coin in essence. It is the probability distribution of a random variable X which is defined on a random experiment that can have two outcomes, ‘0’ or ‘1’. The probability density function of X is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*BafeGrIJEblR7NvIkMiogg.png" /></figure><p>We could also define our probability density function of X in a single mathematical expression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*LOptBSOHiDS4DUgYNhv7_w.png" /></figure><p>1.2. <strong>Examples</strong></p><ul><li>Tossing a “fair” coin and defining: X=1 if Tails, X=0 if Heads, then X follows a Bernoulli distribution with the probability of success equals 0.5.</li><li>A student takes an exam with the probability 80% to pass: X=1 if passes, X=0 if fails, then X follows a Bernoulli distribution with the probability of success equals 0.8.</li><li>A visitor of a website clicks on an ad with probability 2%: X=1 if clicks, X=0 if not, then X follows a Bernoulli distribution with the probability of success equals 0.02.</li></ul><p>1.3. <strong>Basic Properties</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*dpuaQ658NlB7_uY4eFnmBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OexCGshCgY5Ly8SenyZSA.png" /></figure><p>2. <strong>Binomial Distribution</strong></p><p>2.1. <strong>Definition</strong></p><p>In order to introduce <strong>Binomial distribution</strong>, suppose we repeat a Bernoulli trail <em>n</em> times, instead of being interested in the entire sequence of outcomes, we would like to know ‘out of the <em>n</em> trails, how many resulted in a success’. If we defined X as the number of successes in <em>n</em> trails then X follows a Binomial distribution. The probability density function is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*U6SY5RPFQg4cpvJgGgCHSQ.png" /></figure><p>2.2. <strong>Example</strong></p><p>In tossing a ‘fair’ coin 10 times: what is the probability of obtaining 3 heads?</p><p>Note that the ten tosses are mutually independent events, the probability assigned to each toss to any outcome equals 0.5. Hence the result is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nrsP8H7y-G8SNrYriQDKmQ.png" /></figure><p>2.3. <strong>Basic Properties</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*WumI2T7p4rAYVoMBZPmsUQ.png" /></figure><p>3. <strong>Poisson Distribution</strong></p><p>3.1. <strong>Definition</strong></p><p>The <strong>Poisson distribution</strong> is used to model the number of occurrences of an event within a given period. For instances, the problems such like how many customers will walk into the grocery store within next 30 minutes? How many airplanes will request landing permission within the next hour? Given the average number of times the event occurs over that period, the Poisson distribution could deal with these problems.</p><p>However, for the Poisson distribution to be applicable, several conditions has to be hold:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtZ7-9nueffJx14YeO8ZHQ.png" /><figcaption>Conditions for Poisson Distribution — Brilliant.org</figcaption></figure><p>The probability density function of the Poisson distribution is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKxC0owKeZwABDUpRtWS2A.png" /></figure><p>Actually, the formula of the Poisson distribution comes from the Binomial distribution. The mathematic solution are shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKM6SQq1ATYLud3kY5pH2w.png" /></figure><p>3.2. <strong>Example</strong></p><p>One company records the number of vistors that visit their website, they find out that an average of 8 vistors access to their website per hour. Assuming the number of vistors that visit their website follows the Poisson distribution, what is the probability that over 10 vistors access to their website per hour?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jKXtLJbky9avLXIIOVH7_A.png" /></figure><p>Therefore, the probability that over 10 vistors access to the company website per hour is 0.2834.</p><p>3.3. <strong>Basic Properties</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xlx5v9O6rRyc3XysYPlZA.png" /></figure><p><strong>Reference</strong></p><p>Brilliant.org (2020) ‘<em>Possion Distribution</em>’. <a href="https://brilliant.org/wiki/poisson-distribution/">https://brilliant.org/wiki/poisson-distribution/</a></p><p>Emvalomatis, G. (2020) ‘<em>Random Variables and Distributions</em>’ [PowerPoint presentation]. <em>BU52018: Business Analytics</em>.</p><p>Khan Academy (2009) ‘Poisson process 2’. <a href="https://www.youtube.com/watch?v=Jkr4FSrNEVY">https://www.youtube.com/watch?v=Jkr4FSrNEVY</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdce46584633" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistics — ANOVA]]></title>
            <link>https://marvinbu.medium.com/statistics-anova-2fe0e3977284?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fe0e3977284</guid>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[anova]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 07:26:34 GMT</pubDate>
            <atom:updated>2020-10-18T07:26:34.260Z</atom:updated>
            <content:encoded><![CDATA[<h3>Statistics — ANOVA</h3><ol><li><strong>What is ANOVA?</strong></li></ol><p><strong>Analysis of variance (ANOVA) </strong>is a statistical method to find out if the differences between the means of three or more groups are significant. The null hypothesis for ANOVA is that the population means of all groups are equal, while the alternative hypothesis is that at least one mean is significantly different from the rest (As shown below). In other words, ANOVA helps us to figure out whether we need to reject the null hypothesis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdvFCSbuSi4L9D5TEDLfGA.png" /></figure><p>The name ‘ANOVA’ suggests that we are actually analyzing variances between the groups. We would compute a measure of the variance between the means of each group and a measure of the variance within the groups, and examine a test statistic that is the ratio of these measures. The test statistic can be shown to have an F-distribution. Thus, if the F-statistic which we compute exceeds the critical value based on the level of significance we chosen, we would like to reject the null hypothesis.</p><p>2. <strong>Assumptions of ANOVA</strong></p><p>In order to conduct ANOVA, we need several assumptions:</p><ul><li>The samples are randomly and independently obtained.</li><li>The populations from which the samples were obtained must be normally or approximately normally distributed.</li><li>The variances of the populations must be equal.</li></ul><p>3. <strong>Example</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*ObyqUKmtjXKnnqqzsB3X-Q.png" /></figure><p>For example, we have a data set of students from three different schools doing the same test, we might be interested in whether any significant differences exist in the grades among schools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wo7aUbe2tLWkfxnyLK9ihg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BZThrtaRUihcbZwaI6CHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pmzBQu5N20YsatNkRufRwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ar8FkI8B_CqE_yBwxgoUHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AcmmEuyNK1x6c86ZF--5Xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmQEpLU1YRWDuwiwnv4Ezw.png" /></figure><blockquote>The whole idea behind the analysis of variance is to compare the ratio of between group variance to within group variance. If the variance caused by the interaction between the samples is much larger when compared to the variance that appears within each group, then it is because the means aren’t the same.</blockquote><p>Unfortunately, although ANOVA can identify a difference among the means of multiple population, it cannot determine which means are different from the rest. In order to achieve this goal, we could use the Tukey-Kramer multiple comparison procedure.</p><p>4. <strong>Applying the Excel ANOVA Tool</strong></p><p>Actually, Excel provides us an efficient tool to do ANOVA. We could use ‘ANOVA: Single Factor’ from the ‘Data Analysis’ options. By specifying the input range of the data and the level of significance, we could easily derive the result. Below is the result for our example by applying the Excel ANOVA tool:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBTojCC-f0r7C0IjjbGYRw.png" /></figure><p>According to the result, we could also find that the P-value: 0.011583, which is smaller than our chosen level of significance, 0.05, leading to the same conclusion, we would reject the null hypothesis.</p><p><strong>Reference:</strong></p><p>ArmstrongPSYC2190 (2013) ‘One way ANOVA’. <a href="https://www.youtube.com/watch?v=q48uKU_KWas&amp;t=1014s">https://youtu.be/kHwlB_j7Hkc.</a></p><p>Evans, J. (2017) Business Analytics. England: Pearson.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fe0e3977284" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning — Complete Linear Regression]]></title>
            <link>https://marvinbu.medium.com/machine-learning-complete-linear-regression-924f698659b6?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/924f698659b6</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[ordinary-least-square]]></category>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Thu, 17 Sep 2020 06:52:31 GMT</pubDate>
            <atom:updated>2020-09-17T06:52:31.904Z</atom:updated>
            <content:encoded><![CDATA[<h3>Machine Learning — Complete Linear Regression</h3><blockquote>Linear regression is a method that describes dependence relationships, a linear model establishes the relationship between a dependent variable y (Target) and one or more independent variables denoted X (Inputs).</blockquote><p>Let us follow one simple example to get an idea of linear regression, our sample data set is shown below, then we plot them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*yGHlfXt4jflTRLCT1HU-Ag.png" /></figure><p>The values in column ‘<em>GrLivArea</em>’ are independent variables because they are pre-determined, we can not change them by the other variables. The values in column ‘<em>Price</em>’ are dependent variables since we can predict them on changes in the independent variables. Through observation of the diagram, we found there seems to be a positive impact of <em>GrLivArea (X)</em>on the <em>Price (y) </em>of the houses. We could try to fit a line to the graph that describes the ‘average’ impact of <em>X</em> on <em>y. </em>However, how could us find the straight line that fits the data best?</p><p>Basically, we could use either <strong>Ordinary Least Squared (OLS) Method</strong> or an algorithm called <strong>Gradient Descent</strong>.</p><ol><li><strong>Ordinary Least Squared (OLS) Method</strong></li></ol><p>1.1. <strong>Sum of Squared Deviation</strong></p><p>Sum of squared deviation, also called sum of squared errors, is the sum of the squared difference between each dependent variables and the mean of the dependent variables. The deviations here are the difference between actual values (each observations) and predict values (the line). Let us take a look at the mathematical solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M3lRe_nE0Zfri8nolLzMcQ.png" /></figure><p>1.2. <strong>Minimizing the sum of squared deviations</strong></p><p>Following is the process how we get the formula for m and b, with simple linear regression, we could use the outcome formula directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXd_aK9rpGFHWOnQnbIF8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gpNljuYM90H4--XZy6ZEdw.png" /></figure><p>1.3. <strong>Example</strong></p><p>Now we got the solution for the value of <em>m</em> and <em>b</em>, we will see how it works in our example:</p><p>By using the example data set and the formula above, we derive <em>m</em> = 142.02, <em>b</em> = -11954, below is the scatter plot diagram with the best fit line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICLQ5iifZnqs7G5ozab5yw.png" /></figure><p>The<strong> Ordinary Least Squared (OLS) Method </strong>is an efficient way to deal with simple linear regression problems (e.g. single independent variables and single dependent variables). It can deal with linear regression with multiple variables as well. We could substitute <em>b</em> and <em>m </em>as<em> </em>θ0 and θ1, thus, the model could be denoted as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0jJja-nK14pUF1nj9z561A.png" /></figure><p>2. <strong>Gradient Descent</strong></p><p>2.1. <strong>The Hypothesis</strong></p><p>In machine learning, we have a notion of hypothesis, represented as h, which is a function takes X (Inputs) and try to output estimated value. Therefore, we could present our model as following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUHUoJTWI-CUHkEX-IObKw.png" /></figure><p>2.2. <strong>Cost Function</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3h2xSqs1A_qDb-j36IDvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rbEa4mOvMmR-HtzQ4RMEg.png" /></figure><p>2.3. <strong>The Algorithm</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3OIXXrAOnbr8NUKIOEitg.png" /></figure><p>2.4. <strong>Example</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OFH7AuQJos9uIt30vUt2uA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InhVtVZU2OlaZPt5oclaGw.png" /></figure><p>There are three types of <strong>Gradient Descent</strong> algorithm:</p><p><strong>Batch Gradient Descent</strong>: In Batch Gradient Descent, when we calculate the gradient of the cost function, we need to sum up all the training examples for each step. Therefore, if we had a huge data set, it is not appropriate to use this method.</p><p><strong>Stochastic Gradient Descent</strong> (SGD): Instead of using all the training examples for each step in Batch Gradient Descent, SGD uses one randomly selected example or training sample of the data for each step. Depending on the problem, it sometimes could be much faster than Batch Gradient Descent. However, it may cause the problem of error rate jumping around instead of slowly decreasing.</p><p><strong>Mini-Batch Gradient Descent</strong>: This method is a combination of Batch Gradient Descent and SGD, it uses a randomly selected subset of the data at every step. Minni-Batch Gradient Descent creates a balance between the stablity of Batch Gradient Descent and the efficiency of SGD.</p><p><strong>Reference</strong>:</p><p>Andrew Ng (2016) ‘Linear Regression’. <a href="https://youtu.be/kHwlB_j7Hkc">https://youtu.be/kHwlB_j7Hkc</a>.</p><p>Emvalomatis, G. (2020) ‘<em>LinearRegression</em>’ [PowerPoint presentation]. <em>BU52018: Business Analytics</em>.</p><p>Khan Academy (2011) ‘Squared error of regression line’.</p><p>Madhu Sanjeevi (2017) ‘Chapter 1.2: Gradient Descent with Math.’</p><p>Prabhu (2018) ‘Linear Regression Simplified — Ordinary Least Square vs Gradient Descent’.</p><p>StatQuest with Josh Starmer (2019) ‘Gradient Descent, Step-by-Step’. <a href="https://youtu.be/sDv4f4s2SB8">https://youtu.be/sDv4f4s2SB8</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=924f698659b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finance — Investment Appraisal (Discounted Cash Flow Approach — NPV)]]></title>
            <link>https://marvinbu.medium.com/finance-investment-appraisal-discounted-cash-flow-approach-npv-86cc499c8ee8?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/86cc499c8ee8</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[decision-making]]></category>
            <category><![CDATA[investment-management]]></category>
            <category><![CDATA[npv]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 18:32:18 GMT</pubDate>
            <atom:updated>2020-09-12T18:32:18.350Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finance — Investment Appraisal (Discounted Cash Flow Approach — NPV)</h3><p>There are basically two discounted cash flow (DCF) methods of investment appraisal: the net present value (NPV) and the internal rate of return (IRR) methods. This article would take a look at the first one, the NPV investment appraisal method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*P4fRLhQC3v4eWVIAunUA2Q.jpeg" /></figure><p>The NPV investment appraisal method is a straightforward approach that it works on a fundamental principle, whenever the money got out of the investment is equal to or greater than the money put in, the investment is regarded as worth undertaking. Thus, the decision rule of the NPV method would be accept all investments with a zero or a positive net value and reject all those with a negative net value. Because the method is called discounted cash flow approach, the NPV method takes the time value of money into considerations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kK82hOP6goFeK0lIYAk7iA.png" /></figure><p>This formula expresses the sum of the investment discounted future cash flows. According to the decision role, if we calculated the NPV which has a positive or zero value, the company should invest in the project; if the NPV has a negative value, it should not invest.</p><p><strong>Example</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RpwWUi4egcWfAqTCoiANZw.png" /></figure><p><strong>Conclusion</strong>:</p><p>In this article, we get the idea of how the NPV investment appraisal method works and how it calculates. In fact, in order to simplify the analysis, we should specify several assumptions at first, we will list them after we get the basic idea of another method, the IRR method. And also we will try to compare these two methods under some relaxation of the project independence assumptions.</p><p><strong>Reference</strong>:</p><p>Lumby, S. (1981) Investment appraisal and related decisions. Hong Kong: Nelson.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86cc499c8ee8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finance — Investment Appraisal (Traditional Methods)]]></title>
            <link>https://marvinbu.medium.com/finance-investment-appraisal-traditional-methods-c6f83722ce8e?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6f83722ce8e</guid>
            <category><![CDATA[decision-making]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[investment-management]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Mon, 07 Sep 2020 22:06:27 GMT</pubDate>
            <atom:updated>2020-09-07T22:06:27.609Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finance — Investment Appraisal (Traditional Methods)</h3><blockquote>Stephen Lumby(1981) defined an investment decision as one which made by the investors or the top management, involves the company in a cash outlay with the aim of receiving future cash inflows.</blockquote><p>This article will take a look at two traditional methods of investment appraisal, Pay-back and Return on Capital Employed. Before we get to know the methods, we should keep in mind that all investment appraisal methods act as a decision guide, they could not tell investors or decision makers whether to invest or not. However, through investment appraisal, it will help us to communicate information with decision makers. Due to the uncertainty of the future, any investment technique can never replace managerial judgement, nevertheless, it could make the judgement more sound.</p><ol><li><strong>The Payback method</strong></li></ol><p>The name of this method neatly describes the operation of the method, referring to how long does it take to ‘pay back’ the initial capital investment from the incremental benefits. Usually, the benefits being defined as after-tax cash flows. Projects could be ranked in terms of the speed of return, the faster paying-back project is, the more preferred it would be.</p><p><strong>Example</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w9FpOB_p2laWBhaj0e65Mg.png" /></figure><p>One of the advantages of the payback is obvious, it is quick and simply to calculate and easy to understand. To calculate the payback period, the method only takes inputs as initial outlay and annual cash flows. Another advantage of the payback is that it concentrates on the speed of return, this factor could be a dominant short-run consideration for companies with tight liquidity. Additionally, a shorter payback period means a lower risk, thus, as management wish to avoid or minimize risk and uncertainty, the project with fastest payback period is preferred.</p><p>Let us now turn to the disadvantages of the payback. The first is the problem of ignoring the time value of money. This is a very crucial problem of the method as the fact that the money could be invested so as to earn interest as well. One of the other drawbacks of the payback method is that it only considers the period takes to recover the outlay, it does not consider the cash flows that come in subsequent years. As shown in Example, according to the payback method, Project 1 is more preferred, however, if we take a look at Project 2, actually it would generate lucrative cash flows in later years. This means the payback method might mislead the management to cursory decisions. Another problem arises from the fact that usually capital investments are not just one-time investments, the payback method might be not realistic when applying in these scenarios. Finally, the payback method has the problem of setting the maximum payback period criterion, there is no specific guidelines on how the maximum payback period should be determined.</p><blockquote>“The real problem does not stem from the payback concept itself, but more from the way the method is used in the decision making process.”</blockquote><p>2. <strong>Return on Capital Employed</strong></p><p>Return on Capital Employed (ROCE) which usually being known as Accounting Rate of Return (ARR), ROCE is expressed as a percentage ratio of the accounting profit generated by an investment project divided by the required capital outlay. Let us take a look at the formula how to calculate the ROCE ratio:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aH5V3jOiv__ouPPSbgu2LA.png" /></figure><p><strong>Example</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SygkILbICPEEFJa-rXt-Qg.png" /></figure><p>The decision rule: If the expected ROCE for the investment is greater than the <em>target or hurdle rate</em> which determined by the management, then the project should be accepted. When several projects are mutually exclusive, the one with higher ROCE rate is preferred.</p><p>Let us take a look at the advantages of the ROCE method. First, the same as the payback method, it is also easy to calculate and it produces a simple rule in helping the management to accept or reject projects. Another advantage of the ROCE method is that it provides a percentage rate of return which the financial management is very familiar with, unlike the payback method, it considers the profits throughout the whole project life.</p><p>However, the ROCE method also suffers from several disadvantages. First, it is the ambiguous nature of the ROCE concept, there is no general agreement in calculating the variants (As shown in the formula, we can use initial capital costs or average capital investment). Second, the method provides a percentage rate, it is unable to compare the financial size between projects. Third, although the method does take into account the profits throughout the whole project life, when comparing between projects, it ignores the difference in the length of life between projects which is crucial when considering the uncertainty, liquidity etc. of the projects. Finally, the same as the payback method, the problem of ignoring the time value of money.</p><p><strong>Conclusion</strong></p><p>Both the payback method and the ROCE method are widely used in investment decisions, each has its own advantages and disadvantages. It is not easy to tell which one is superior, on the contrary, it is common to find that the methods are usually combined to produce a ‘two-tier’ decision rule, for example, ‘projects may be accepted only if (say) they payback within five years <em>and</em> have a minimum ROCE of 12%’. However, these two traditional methods of investment appraisal still facing the problem of ignoring the time value of money.</p><p><strong>Reference</strong></p><p>Lumby, S. (1981) Investment appraisal and related decisions. Hong Kong: Nelson.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6f83722ce8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistics — Hypothesis Testing]]></title>
            <link>https://marvinbu.medium.com/statistics-notes-hypothesis-testing-c73f1bfd4e14?source=rss-b2ab1a907d41------2</link>
            <guid isPermaLink="false">https://medium.com/p/c73f1bfd4e14</guid>
            <category><![CDATA[critical-value]]></category>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Bu Yifan]]></dc:creator>
            <pubDate>Sat, 29 Aug 2020 23:53:27 GMT</pubDate>
            <atom:updated>2020-09-10T04:03:29.824Z</atom:updated>
            <content:encoded><![CDATA[<h3>Statistics — Hypothesis Testing</h3><blockquote>“A thesis is something that has been proven to be true. A hypothesis is something that has not yet been proven to be true.”</blockquote><ol><li><strong>The null hypothesis</strong></li></ol><p>The procedure of hypothesis testing aims to determine whether the given hypothesis is true or not through statistical methods. The first step of hypothesis test is to set up the null hypothesis. A null hypothesis is an assertion about the value of a population parameter. It is considered to be true until we have sufficient statistical evidence to reject. For example, a delivery vendor claims that his company could deliver parcels, on the average, in at most 3 working days. You suspect that the average is greater than 3 working days and would like to test it. The null hypothesis would be set up as following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*ah8kMwsF3XdQs8_IqVZ4fQ.png" /></figure><p>We put what we would like to reject in the null hypothesis (we usually put equal sign in the null hypothesis), we use data and statistical procedures to <strong>reject</strong> or <strong>fail to reject</strong> the null hypothesis. The alternative hypothesis is the negation of the null hypothesis, thus, in this case, the alternative hypothesis would be set up as following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*inb1IYICIg7DrB9kk4U0pQ.png" /></figure><p>The null hypothesis and the alternative hypothesis are exactly opposite statements, thus, only one of them could be true. However, we could never be one hundred percentage certain that whether we are right in rejecting or failing to reject the null hypothesis.</p><p>2. <strong>Type I and Type II error</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*Bc0vJxvLd_r6m5IX9O5tkA.png" /></figure><p>As shown in the table, there are total two kinds of error situations could occur while testing. A Type I error means rejecting a null hypothesis when it is true, a Type II error means fail to reject a null hypothesis when it is false. <em>A significance level</em> is always attached while doing the test,<em> a significance level</em> is the probability of committing Type I error. A 5% <em>significance level</em> corresponds to 95% confidence interval. We could reduce the probability of committing Type I error by lowering the <em>significance level</em> when testing, however, meanwhile the probability of committing Type II error will be increasing.</p><p>3. <strong>Hypothesis testing about the mean</strong></p><p>Before we doing the test we should distinguish between large samples and small samples, i.e. using the values of a z table or t-distribution.</p><p><strong>Large samples</strong>: Testing about the mean (known the population standard deviation)</p><p><strong>Example</strong>: A chocolate manufacturer sold in 200g packs. We want to put a claim that the weights of the packs actually distributed over 200g, from previous data we know that the standard deviation of the weights of the packs is 18g. We take a random sample of 36 packs and find the sample mean 203g.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0WSoKr3ljQXdaifa7a8Cw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*UazhjPAcxgSuPW7YXAxrdw.png" /></figure><p>If our test statistic is below the critical value (for lower-tail tests) or above the critical value (for upper-tail tests), then we reject the null hypothesis.</p><p><strong>Small samples</strong>: Testing about the mean (unknown the population standard deviation)</p><p>Because the population standard deviation is unknown (most cases in real-world, the population standard deviation is unknown), thus, we could use an estimation, the sample standard deviation instead of population standard deviation in the formula of z statistic.</p><p>The statistic no longer has a standard normal distribution, the statistic follows a <em>t</em> distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXY7vnDNUYrsAOMH320PPg.png" /></figure><p>4. <strong>Hypothesis testing about the variance</strong></p><p><strong>Example</strong>: The chocolate manufacturer want to test (reject) the population variance of the weights of the packs is greater than 100. We take a random sample of 36 packs and find the sample variance is 81.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_FX4wnDxGp8ZtR43T-UeYg.png" /></figure><p>5. <strong>Conclusion</strong></p><p>The steps of hypothesis testing:</p><p>1- Formulate the null hypothesis and the alternative hypothesis, we put the claim we would like to reject in the null hypothesis.</p><p>2- Calculate the test statistics.</p><p>3- Check the table of the values for the critical value and decide whether to reject or fail to reject the null hypothesis.</p><p><strong>Reference</strong></p><p>Aczel, A. D. and Sounderpandian, J. (2009) Complete Business Statistics. New York: McGraw-Hill/Irwin.</p><p>Emvalomatis, G. (2020) ‘<em>HypothesisTesting</em>’ [PowerPoint presentation]. <em>BU52018: Business Analytics</em>.</p><p>Ozdemir, D. (2016) Applied Statistics for Economics and Business. Switzerland: Springer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c73f1bfd4e14" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>