<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Articles on Shuyan Mei</title>
    <link>https://shuyanmei.github.io/documentation/</link>
    <description>Recent content in Articles on Shuyan Mei</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Thu, 02 Mar 2017 12:00:00 -0500</lastBuildDate>
    <atom:link href="https://shuyanmei.github.io/documentation/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>A Summary of Book Trustworthy Online Controlled Experiments</title>
      <link>https://shuyanmei.github.io/documentation/fourth_post/</link>
      <pubDate>Mon, 18 Jan 2021 14:48:25 -0500</pubDate>
      <guid>https://shuyanmei.github.io/documentation/fourth_post/</guid>
      <description>&lt;p&gt;Recently I finished reading the book Trustworthy Online Controlled Experiments, and here I put together my reading notes.&lt;/p&gt;
&lt;p&gt;The book has five parts. The first two parts are a high-level introduction of online controlled experiments. Why do we need to conduct controlled experiments? What is the evaluation metric for the experiments? The last three parts are more technically focused. The third part introduces some alternative methods when controlled experiments are not feasible. The fourth part focused on building the experimental platform. The last part mainly focused on how to analyze results from our experiments, what are the potential pitfalls and methods to improve it.&lt;/p&gt;
&lt;h1 id=&#34;1-why-should-we-use-ab-testing&#34;&gt;1. Why should we use A/B Testing?&lt;/h1&gt;
&lt;p&gt;Imagine we introduce a new feature into our online service, and we see an increase in traffic. Can we claim that if we roll out the feature to all customers can increase user engagement? Not necessarily. The feature can be positively or negatively correlated with traffic or have nothing to do with traffic. A/B testing can help with establishing causality with high confidence, have more power to detect small/unexpected changes.&lt;/p&gt;
&lt;h1 id=&#34;2-how-to-design-the-experiment&#34;&gt;2. How to design the experiment?&lt;/h1&gt;
&lt;h2 id=&#34;21-create-metric-based-on-objective&#34;&gt;2.1 Create metric based on objective&lt;/h2&gt;
&lt;p&gt;In reality, we usually have more than one business metric to use in experimental design. These metrics must be measurable, attributable, sensitive, and timely. One way to combine multiple metrics is to normalize each metric and then create a weighted combination of them, such as credit score. To decide how many metrics to use, one rough rule of thumb is to limit the number of metrics to five. Because of multiple testing problem, if we have too many metrics, the probability of seeing a significant result is high.&lt;/p&gt;
&lt;h2 id=&#34;22-aa-test&#34;&gt;2.2 A/A test&lt;/h2&gt;
&lt;h3 id=&#34;why-we-need-aa-test&#34;&gt;Why we need A/A test?&lt;/h3&gt;
&lt;p&gt;A/A test is almost the same as the A/B test, but the treatment and control group receive the same treatment.
Some benefits of running the A/A test.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Ensure no bias between the treatment and control group. For example, if we use the same users in the last experiment in the current experiment, there might be residual effects, tests from the last experiment can influence the current experiment.&lt;/li&gt;
&lt;li&gt;Assess metric variability. If we have more and more data over time, we want to see how the data distribution change over time.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;how-to-run-aa-test&#34;&gt;How to run A/A test?&lt;/h3&gt;
&lt;p&gt;Simulate thousands of experiments, check if the distribution of p-value is uniform. Sometimes running thousands of tests can be expensive. One workaround is to use data from the previous experiment. For example, we stored the experiment results from last week, and then reassign the user into the treatment and control group, and then calculate the p-value. To check if the distribution follows a uniform distribution, we can run the goodness-of-fit test such as Anderson-Darling and Kolmogorov–Smirnov (KS) to check if it follows a uniform distribution.&lt;/p&gt;
&lt;h3 id=&#34;aa-test-fails&#34;&gt;A/A test fails?&lt;/h3&gt;
&lt;p&gt;The reason could be outliers in the data or
metric has a highly skewed distribution. In this case, we can cap the data.&lt;/p&gt;
&lt;h2 id=&#34;23-choose-significance-level-power&#34;&gt;2.3 Choose significance level, power&lt;/h2&gt;
&lt;p&gt;The significance level is the one we compare with the p-value, if the p-value is less than the significance level, then we can say that the p-value is significant, which means that we should reject the null hypothesis.&lt;/p&gt;
&lt;p&gt;Power is the probability the test can detect the significance difference(positive) when it is actually positive.&lt;/p&gt;
&lt;h2 id=&#34;24-calculate-sample-size&#34;&gt;2.4 Calculate sample size&lt;/h2&gt;
&lt;p&gt;Based on the power and significance level, we can calculate the sample size we need for the experiment.&lt;/p&gt;
&lt;p&gt;Besides, to play around with significance level and power, we can also transform or cap the metric to change the required sample size.&lt;/p&gt;
&lt;p&gt;For metrics that have higher skewness, if we do some transformation or cap it. Then the required sample size will be reduced.&lt;/p&gt;
&lt;h2 id=&#34;25-decide-timepopulationunit-to-run-the-experiments&#34;&gt;2.5 Decide time/population/unit to run the experiments&lt;/h2&gt;
&lt;p&gt;Since some users will only visit the website once in the online experiment, thus duration is also important when considering sample size.&lt;/p&gt;
&lt;p&gt;The usual approach is the randomization unit and analysis unit are the same. One example is the randomization unit is user, and the analysis unit is click-per-user, then the calculation is easier to compute.  But if the randomization unit is different than the analysis unit, for example, if the randomization unit is user, but the analysis unit is click-through-rate-per-page, then if a bot exists, it can generate thousands of page view using one user ID, in this case, we can limit the number of page-view per user to avoid such outliers. We need to use the bootstrap and delta method.&lt;/p&gt;
&lt;p&gt;The most common one is user-based randomization. We can track it by user login-ID, cookie ID.&lt;/p&gt;
&lt;h2 id=&#34;26-analyze-results&#34;&gt;2.6 Analyze results&lt;/h2&gt;
&lt;h3 id=&#34;irrelevant-metric-significant-multiple-testing-problem&#34;&gt;Irrelevant metric significant: multiple testing problem&lt;/h3&gt;
&lt;p&gt;When we run thousands of tests, or on different metrics, it is likely we get significant results even they do not make sense. This is also known as the multiple testing problem. One solution is to separate metrics into different tiers. For each tier, we give them a different significance level.
Another common solution to the multiple testing problem is Bonferroni correction.&lt;/p&gt;
&lt;h3 id=&#34;improve-powersensitivity&#34;&gt;Improve power/sensitivity&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Choose the metric that has a smaller variance&lt;/li&gt;
&lt;li&gt;Transform metric through cap, binarization, log transformation.&lt;/li&gt;
&lt;li&gt;Triggered analysis&lt;/li&gt;
&lt;li&gt;Stratification&lt;/li&gt;
&lt;li&gt;Randomization at a more granular level&lt;/li&gt;
&lt;li&gt;Paired experiment&lt;/li&gt;
&lt;li&gt;Pool control groups&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;sample-ratio-mismatch-srm&#34;&gt;Sample Ratio Mismatch (SRM)&lt;/h3&gt;
&lt;p&gt;SRM is a guardrail metric that ensures the validity of the experiment results. When we set up the experiment, we have a ratio of users between the treatment and control group, the experimental results should close to the experimental design ratio. When the p-value from the t-test or chi-square test is low, then there is a problem of SRM. The metrics we used are likely to be invalid.&lt;/p&gt;
&lt;h3 id=&#34;novelty-effects&#34;&gt;Novelty effects&lt;/h3&gt;
&lt;p&gt;When the new feature introduced, users might be uses a lot due to it is new, and as time goes by, the users might use it much less. One way to detect this is to plot usage over time.&lt;/p&gt;
&lt;h1 id=&#34;3-when-is-ab-testing-not-a-good-idea&#34;&gt;3. When is AB testing not a good idea?&lt;/h1&gt;
&lt;p&gt;There are cases when A/B testing is not working.&lt;/p&gt;
&lt;h3 id=&#34;1-we-can-not-control-user-behavior&#34;&gt;1. We can not control user behavior.&lt;/h3&gt;
&lt;p&gt;For example, we can not control certain user behavior. such as ask the user to switch their phone.&lt;/p&gt;
&lt;h3 id=&#34;2-high-opportunity-cost&#34;&gt;2. High opportunity cost&lt;/h3&gt;
&lt;p&gt;If users do not receive treatment, we might lose money. For example, we want to run the ad on the event only happens once a year.&lt;/p&gt;
&lt;h3 id=&#34;3-leakage-and-interference-between-variants&#34;&gt;3. Leakage and Interference between variants&lt;/h3&gt;
&lt;p&gt;If the users are interacting with each other, also known as the network effect, then control and treatment groups are not independent. In this case, we need to create isolation to make sure that the units in the treatment and control group are independent. For example, we can use geometric-based isolation when conducting design on a social network.&lt;/p&gt;
&lt;h3 id=&#34;4-experiments-require-a-long-time-to-take-effects&#34;&gt;4. Experiments require a long time to take effects&lt;/h3&gt;
&lt;p&gt;There are some experiments that require a longer time to run. The long term and short term effect can be different. Below are several reasons.&lt;/p&gt;
&lt;p&gt;User-learned effect: The user might need a longer time to learn the new feature.&lt;/p&gt;
&lt;p&gt;Delayed effect: There is a large time gap between the feature launch to the time the treatment takes effect. For example, there could be months between a customer book a hotel to actually go there.&lt;/p&gt;
&lt;p&gt;Network effect: For example, in a two-sided marketplace, introduce a new feature can increase the demand, but the supply needs time to catch up, thus the treatment effects take longer to measure.&lt;/p&gt;
&lt;p&gt;Ecosystem change: Policy changes, seasonality, competitor&amp;rsquo;s similar features.&lt;/p&gt;
&lt;p&gt;Keep the experiment running for a long time can introduce survivor bias, and the feature can also interact with other new features as time evolves.&lt;/p&gt;
&lt;p&gt;Alternative methods such as cohort analysis, the reverse experiment can be used to measure the long-term effect.&lt;/p&gt;
&lt;h1 id=&#34;4-alternative-methods-when-ab-testing-is-expensive-or-not-feasible&#34;&gt;4. Alternative methods when AB testing is expensive or not feasible&lt;/h1&gt;
&lt;p&gt;The observational causal study is one method when the controlled experiment is not feasible.&lt;/p&gt;
&lt;h2 id=&#34;41-observational-causal-study&#34;&gt;4.1 observational causal study&lt;/h2&gt;
&lt;p&gt;Outcome for treated -Outcome for untreated
= Outcome for treated - Outcome for treated if not treated +
Outcome for treated if not treated - Outcome for untreated if treated
= Impact of treatment on treated + Selection Bias&lt;/p&gt;
&lt;p&gt;If it is a randomized controlled experiment, then the expected value of selection bias is zero. But in cases mentioned in part 4, it is not. That is why causal study comes into play. In contrast to A/B testing, the causal study has no randomized assignment on the unit, it looks at historical data. Though both causal study and retrospective data analysis are using historical study. The goals are different, the goal of the causal study is to find the causality relationship.&lt;/p&gt;
&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;h4 id=&#34;1-interrupted-time-series-its&#34;&gt;1. Interrupted time series (ITS)&lt;/h4&gt;
&lt;p&gt;ITS is a quasi-experimental design, which we can control the change, but not randomize the unit. We test the treatment/control of the same population over time. The main confounding effect is the time-based effect such as seasonality.&lt;/p&gt;
&lt;h4 id=&#34;2-interleaved-experiment&#34;&gt;2. Interleaved experiment&lt;/h4&gt;
&lt;p&gt;Interleaved experiment is commonly used to evaluate the ranking algorithm. One example is to mix results from two algorithms, and then compare the click-through-rate from two algorithms.&lt;/p&gt;
&lt;h4 id=&#34;3-regression-discontinuity-design-rdd&#34;&gt;3. Regression Discontinuity Design (RDD)&lt;/h4&gt;
&lt;p&gt;RDD is commonly used when there is a clear threshold that identifies the treatment group. We select the group which has a threshold right above the threshold as the treatment group, and those with a threshold right below the threshold as the control group. By doing this, it can reduce selection bias. One main issue of RDD is again the confounding effects. The results can be contaminated if there is another important factor that has the same threshold. For example, if we want to test the alcohol assumption at legal drinking age 21, but gambling legal age is also 21.&lt;/p&gt;
&lt;h4 id=&#34;4-instrumental-variableiv-and-natural-experiment&#34;&gt;4. Instrumental variable(IV) and Natural Experiment&lt;/h4&gt;
&lt;p&gt;IV approximate the random assignment.  For example, to compare the earnings between Veterans, an instrument can be the Vietnam war draft lottery. Natural experiment
, such as twins in twins medicine study.&lt;/p&gt;
&lt;h4 id=&#34;5-propensity-score-matching&#34;&gt;5. Propensity score matching&lt;/h4&gt;
&lt;p&gt;Similar to stratified sampling, PSM segment users into groups by matching on a constructed propensity score.&lt;/p&gt;
&lt;h4 id=&#34;6-difference-in-difference-dd&#34;&gt;6. Difference in difference (DD)&lt;/h4&gt;
&lt;p&gt;We make a treatment to treatment group at a certain time T, and then we note the difference of treatment group before and after time T, compare it with the difference of control group before and after time T. The difference in the control group over time can capture external factors such as seasonality, inflation.&lt;/p&gt;
&lt;h3 id=&#34;pitfalls&#34;&gt;Pitfalls&lt;/h3&gt;
&lt;p&gt;Confounding effects and deceptive correlations are common pitfalls in observational causal studies.&lt;/p&gt;
&lt;h2 id=&#34;42-more-methods&#34;&gt;4.2 More methods&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;User experience research&lt;/li&gt;
&lt;li&gt;Focus group&lt;/li&gt;
&lt;li&gt;Survey&lt;/li&gt;
&lt;li&gt;Log-based analysis&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The methods above can also be used when A/B testing is not feasible or expensive to run.&lt;/p&gt;
&lt;h1 id=&#34;references&#34;&gt;References:&lt;/h1&gt;
&lt;p&gt;Kohavi, R., Tang, D., &amp;amp; Xu, Y. (2020). Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing. Cambridge: Cambridge University Press. doi:10.1017/9781108653985&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Optimization Learning Notes</title>
      <link>https://shuyanmei.github.io/documentation/optimization-notes/</link>
      <pubDate>Mon, 28 Dec 2020 16:28:27 -0500</pubDate>
      <guid>https://shuyanmei.github.io/documentation/optimization-notes/</guid>
      <description>&lt;p&gt;&lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css&#34;&gt;
  &lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js&#34;&gt;&lt;/script&gt;
  &lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/contrib/auto-render.min.js&#34;&gt;&lt;/script&gt;&lt;/p&gt;

&lt;p&gt;In the past year, I started to pick up some optimization algorithms in work to solve problems like finding optimal prices to maximize business&#39; profits with constraints. While memory is still fresh, I decided to write down my learning notes here. This is not an exhaustive survey of optimization algorithms, it only serves as the learning notes of the optimization algorithms which I have exposed so far.&lt;/p&gt;

&lt;h2 id=&#34;optimization-overview&#34;&gt;Optimization Overview&lt;/h2&gt;

&lt;p&gt;There are different ways to categorize the optimization algorithm. Depends on the objective function, we can have linear or non-linear optimization. Based on the input type, we can have numeric optimization and discrete optimization. There are optimizations with constraints and without any constraints. Depends on the number of objective functions, we can have single and multiple objective optimizations.&lt;/p&gt;

&lt;h2 id=&#34;1-no-constraints-and-differentiable-objective-function&#34;&gt;1. No constraints and differentiable objective function&lt;/h2&gt;

&lt;p&gt;The first scenario that comes to my mind is when we have a differentiable objective function without any constraints.&lt;/p&gt;

&lt;h2 id=&#34;11-gradient-descent&#34;&gt;1.1 Gradient Descent&lt;/h2&gt;

&lt;p&gt;When we are searching the values, Gradient descent tries to go in the direction such that the value of cost function f(x+\delta x) at the next step is smaller than the current one f(x).
To find the direction of the movement, we take the derivative of the function at each step, assume the function is differentiable. Depends on how far we move each step, the algorithm can take a long time to converge, or even not converges.&lt;/p&gt;

&lt;h2 id=&#34;12-newton-method&#34;&gt;1.2 Newton Method&lt;/h2&gt;

&lt;p&gt;If the cost function is also twice differnetiable, then we can use newton method, and quasi newton method according to Taylor expansion.&lt;/p&gt;

&lt;h4 id=&#34;taylor-expansion&#34;&gt;Taylor Expansion&lt;/h4&gt;

&lt;p&gt;Given a real or complex twice differentiable function f, then the value at point &lt;span  class=&#34;math&#34;&gt;\(x_0\)&lt;/span&gt; can be approximated as &lt;span  class=&#34;math&#34;&gt;\( f(x_0) + f&#39;(x_0)(x-x_0) + \frac{1}{2}f&#39;(x_0)(x-a)^2 \)&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The Newton Method, not only takes the direction of the movement but also the velocity(second derivative) into account. Therefore, using the Newton method is more efficient when updating each step. But sometimes we don&#39;t have the second derivative.&lt;/p&gt;

&lt;h2 id=&#34;13-quasinewton-method&#34;&gt;1.3 Quasi-Newton Method&lt;/h2&gt;

&lt;p&gt;To solve the problem of the newton method in the case we don&#39;t have the second derivative, Quasi-Newton can be used. The main difference is that Quasi-Newton uses an approximation of the second derivative to replace the derivative to do the computation.&lt;/p&gt;

&lt;h2 id=&#34;14-why-not-use-an-analytical-solution&#34;&gt;1.4 Why not use an analytical solution?&lt;/h2&gt;

&lt;p&gt;Consider that since we can take the derivatives, why not just set the derivative of the objective function as zero, and then solve analytically. One main reason is that sometimes we have a huge dataset and multiple variables, the computation time can be longer if we need to do matrix transformation, but gradient descent or the newton method is iterative, so it can be less expensive.&lt;/p&gt;

&lt;h2 id=&#34;2-not-differentiable&#34;&gt;2. Not differentiable?&lt;/h2&gt;

&lt;p&gt;In reality, we do not have such optimistic cases. Not every objective function is differentiable. Consider a discrete case below.&lt;/p&gt;

&lt;h3 id=&#34;example-the-traveling-salesman&#34;&gt;Example, the traveling salesman&lt;/h3&gt;

&lt;p&gt;The traveling salesman is a classical discrete optimization problem. The salesman starting from city A, and travel N cities, and only one time for each city, and eventually come back to city A, what is the shortest path?&lt;/p&gt;

&lt;p&gt;In this case, we can not find an analytical solution.
The brute force solution is that we iterate all permutation which has a time complexity of O(N!). There are algorithms we can use here such as simulated annealing, GA, random hill climbing.&lt;/p&gt;

&lt;p&gt;I summarize the algorithms below. These algorithms can be effective in discrete cases.&lt;/p&gt;

&lt;h2 id=&#34;21-genetic-algorithm&#34;&gt;2.1 Genetic Algorithm&lt;/h2&gt;

&lt;p&gt;Genetic algorithm is one type of evolutionary algorithm. The algorithm uses the idea from biology to mimic natural selection.
Take the traveling salesman as an example. The genetic algorithm first randomly generates a population (a set of routes), and then rank the routes by fitness, in this case, it is the shortest distance. The next step is to randomly select two routes as the &#39;parent route&#39;
and pass the elements in each parent route to make a &#39;child&#39;. This process is known as crossover. To explore more possibilities, the final step is to perform mutation which is randomly select two cities in each parent route to swap with a predefined probability(say 3%)
The child serves as the next generation and we repeat to full. Over time, it will generate a better(shorter distance) generation.&lt;/p&gt;

&lt;p&gt;Because of the mutation and crossover, We do not always reach the global optimal but can reach the local optimum fairly quickly.&lt;/p&gt;

&lt;h2 id=&#34;22-simulated-annealing&#34;&gt;2.2 Simulated Annealing&lt;/h2&gt;

&lt;p&gt;This algorithm&#39;s idea comes from annealing the metal. If we cool the meta fast, then the irons in the meta are randomly spread, but if we cool it slowly, then it will be more structured, and more stable.
The algorithms work in the following way. We have an initial temperature, and in the next step, we evaluate the fitness of the route and decide whether to switch to the next possible route with a probability. The probability is associated with temperature. We decrease temperature over time, so we are less likely to back to the previous path. By doing this, we are less likely to be stuck at a local minimum. More likely to reach the global optimum.&lt;/p&gt;

&lt;h2 id=&#34;23--hillclimbing-with-random-restart&#34;&gt;2.3  Hill-Climbing with Random Restart&lt;/h2&gt;

&lt;p&gt;Hill climbing is straightforward as its name suggests.  We start with a random path and find the neighbor path, compare it with the current path to see if it is better, if it is, then we select the next path. The problem is also about stuck at a local minimum. Then we introduce random restart into it, so it does not get into local optimum.&lt;/p&gt;

&lt;h2 id=&#34;3-optimization-with-constraints&#34;&gt;3. Optimization with constraints&lt;/h2&gt;

&lt;p&gt;In reality, we usually have constraints when doing optimization. Based on the constraint type, there are different methods to optimize.&lt;/p&gt;

&lt;h3 id=&#34;31-lagrange-multiplier-for-equality-constraint-only&#34;&gt;3.1 Lagrange multiplier for Equality constraint only&lt;/h3&gt;

&lt;p&gt;If the constraint can be expressed as equality,  Then we can use Lagrange Multiplier to solve the algorithm. For example, a retail business wants to maximize its profits given certain constraints of the budget. The cost is labor and raw material. Revenue is a function of labor and raw material. In this scenario, we want to maximize the revenue function f. Let x, y denote the labor cost and raw material. Then both f and the cost function g are functions of x and y. We want to max out the budget, thus g(x,y) ideally should be equal to budget (c).&lt;/p&gt;

&lt;p&gt;The optimization problem can be formulated as the following.&lt;/p&gt;

&lt;p&gt;&lt;span  class=&#34;math&#34;&gt;\[
max f(x,y)
\]&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;given the constraint that
&lt;span  class=&#34;math&#34;&gt;\(
g(x,y)= c
\)&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;where c is a constant.&lt;/p&gt;

&lt;p&gt;&lt;img src=&#34;https://shuyanmei.github.io/lm.png&#34; alt=&#34;drawing&#34; width=&#34;400&#34; height=&#34;400&#34;/&gt;&lt;/p&gt;

&lt;p&gt;We want the coutour to barely touch the constraints. To do that, the vector perpendicular to the tangent line at that intersection point should go the same direction as the gradient of the constraint function.&lt;/p&gt;

&lt;p&gt;That is to say,&lt;/p&gt;

&lt;p&gt;&lt;span  class=&#34;math&#34;&gt;\[
\nabla f = \lambda \nabla g
\]&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;which is equivalent to&lt;/p&gt;

&lt;p&gt;&lt;span  class=&#34;math&#34;&gt;\[
\frac{\partial f}{\partial x}  = \lambda \frac{\partial g}{\partial x}
\]&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span  class=&#34;math&#34;&gt;\[ 
\frac{\partial f}{\partial y}  = \lambda \frac{\partial g}{\partial y} 
\]&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;where  &lt;span  class=&#34;math&#34;&gt;\( \lambda \)&lt;/span&gt; is a constant.
Solve the equation above, we can get the value of x and y.&lt;/p&gt;

&lt;h3 id=&#34;32-interior-point-method-for-inequality-constraints&#34;&gt;3.2 Interior point method for inequality constraints&lt;/h3&gt;

&lt;p&gt;However, the above case is a very strict constraint. There are times we face an inequality constraint. In this case, we can use the interior point method such as the barrier function to convert it to a non-constrain problem and then solve it.&lt;/p&gt;

&lt;h2 id=&#34;references&#34;&gt;References&lt;/h2&gt;

&lt;p&gt;[1] &lt;a href=&#34;https://en.wikipedia.org/wiki/Quasi-Newton_method&#34;&gt;https://en.wikipedia.org/wiki/Quasi-Newton_method&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[2] &lt;a href=&#34;https://www.khanacademy.org/math/multivariable-calculus/applications-of-multivariable-derivatives/lagrange-multipliers-and-constrained-optimization/v/lagrange-multiplier-example-part-1&#34;&gt;https://www.khanacademy.org/math/multivariable-calculus/applications-of-multivariable-derivatives/lagrange-multipliers-and-constrained-optimization/v/lagrange-multiplier-example-part-1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[3] &lt;a href=&#34;https://en.wikipedia.org/wiki/Interior-point_method&#34;&gt;https://en.wikipedia.org/wiki/Interior-point_method&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;script&gt;renderMathInElement(document.body);&lt;/script&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Are you satisfied with your job as a developer?</title>
      <link>https://shuyanmei.github.io/documentation/third-post/</link>
      <pubDate>Wed, 05 Sep 2018 00:00:00 +0000</pubDate>
      <guid>https://shuyanmei.github.io/documentation/third-post/</guid>
      <description>&lt;p&gt;&lt;img src=&#34;https://shuyanmei.github.io/stackoverflow.jpg&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Tech industry has been booming for years. We hear a lot of stories of peaks such as competitive salaries, work-life balance, unlimited vacation one can get working in a tech company.  But are the employees really happy with their jobs? What drives their satisfaction and what makes them to leave?&lt;/p&gt;
&lt;p&gt;I used data from Stackoverflow&amp;rsquo;s 2017 Annual Developer Survey to investigate this problem.&lt;/p&gt;
&lt;p&gt;This survey has around 64000 reviews from 213 countries. The survey&amp;rsquo;s responses are mostly collected from developers and the questions asked in the survey are related to many aspects of developer&amp;rsquo;s job and career. Some of the aspects covered:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;How do they break into this field at the first place?&lt;/li&gt;
&lt;li&gt;The developer&amp;rsquo;s education, especially coding background&lt;/li&gt;
&lt;li&gt;The developers&#39; job responsibility and satisfaction&lt;/li&gt;
&lt;li&gt;What makes them to looking for new opportunity? What they value most when they look for the next position?&lt;/li&gt;
&lt;li&gt;The developers&#39; interaction with Stackoverflow.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here I am interested in dig dive into data to figure out three problems.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Part I How satisfied are you as a developer ?&lt;/strong&gt;
There is one rating question in the survey asking about the job satisfaction. The answer is rated from 0-10 which 10 represents highly satisfied and 0 represents highly dissatisfied. I first filter out responses with NA values. Below is a table showing the response counts and percentage for each rating.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Job Satisfaction&lt;/th&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Rating Counts&lt;/th&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Percentage&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;8.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;8983&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;22.25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;7.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;7969&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;19.74%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;9.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;5573&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;13.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;6.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4726&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;11.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;10.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4148&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;10.27%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;5.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;3749&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;9.29%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1865&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4.62%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;3.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1635&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4.05%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;2.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;888&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;2.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;0.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;467&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1.16%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1.0&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;373&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;0.92%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Here, I used a metric called &amp;lsquo;top 3 box&amp;rsquo; to measure satisfaction. A Top 3 Box score summarizes the positive responses from a scale survey question. It combines the highest 3 responses of the scale to create one single number.&lt;/p&gt;
&lt;p&gt;Below plot shows the job satisfaction by country using the metric top 3 box. The countries I selected here have a response threshold of 500.
&lt;img src=&#34;https://shuyanmei.github.io/JSbyCty.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;Top countries for satisfaction score are Netherlands, Canada,  Sweden and United States. All these four countries has over 50% top 3 box score.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Part II Does salary drive satisfaction? Is there anything else?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are many factors which can drive job satisfaction, such as salary, health benefits and vacation. To figure out does salary drives job satisfaction. I check the average salary of the top five countries which has the highest average salary.&lt;/p&gt;
&lt;p&gt;Below tables shows the average salary of these countries.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Country&lt;/th&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Average Salary&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;United States&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;86862.40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Canada&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;60821.54&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;United Kingdom&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;56086.99&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Germany&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;44121.32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;India&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;11603.47&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The top countries with high average salaries also have a high job satisfaction (except India). Salary does have some impact on the job satisfaction. In addition to salary, does the benefits also influence employees&amp;rsquo;s satisfaction?&lt;/p&gt;
&lt;p&gt;One of the survey&amp;rsquo;s question is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;When it comes to compensation and benefits, other than base salary, which of the following are most important to you?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The following table shows the counts of each factors people think is most important to them.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Important Benefits&lt;/th&gt;
&lt;th style=&#34;text-align:center&#34;&gt;Counts&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Vacation/days off&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;5757&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Health benefits&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4455&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Expected work hours&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4288&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Remote options&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;5008&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Retirement&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;2658&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Annual bonus&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;2983&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Equipment&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;4002&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Professional development sponsorship&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;3615&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Stock options&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1300&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Child/elder care&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;694&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Long-term leave&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1240&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Meals&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1258&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Other&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;247&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Private office&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;872&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Education sponsorship&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;1287&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;Charitable match&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;199&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:center&#34;&gt;None of these&lt;/td&gt;
&lt;td style=&#34;text-align:center&#34;&gt;82&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The top three factosr are vacation, health benefits and expected work hours.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Part III Why people leaved their job?&lt;/strong&gt;
To figure out why people are leaving their job, I took a closer look at below question in the survey.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;You said before that you used to code as part of your job, but no longer do. To what extent do you agree or disagree with the following statements?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The top three reasons for people to quit coding are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I don&amp;rsquo;t think my coding skills are up to date&lt;/li&gt;
&lt;li&gt;If money weren&amp;rsquo;t an issue, I would take a coding job again&lt;/li&gt;
&lt;li&gt;My career is going the way I thought it would 10 years ago&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;and they counts for 17%, 17% and 15% of the total respectively.&lt;/p&gt;
&lt;p&gt;The technical skills is the most essential for developer. One need to keep updated for their coding skills. Just as important as coding skills, money also factors into developer&amp;rsquo;s career decision. At the same time, some of the developers are looking for a career change and they do want to try out different things. That is also one reason they left their job.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Hello World!</title>
      <link>https://shuyanmei.github.io/documentation/heyyyy/</link>
      <pubDate>Sat, 25 Aug 2018 00:00:00 +0000</pubDate>
      <guid>https://shuyanmei.github.io/documentation/heyyyy/</guid>
      <description>&lt;p&gt;Hello, I finally got my first personal webpage set up!&lt;/p&gt;
&lt;p&gt;I will use this website to share some of my projects in statistics, machine learning or programming.&lt;/p&gt;
&lt;p&gt;This website is hosted on Github and I used &lt;a href=&#34;https://gohugo.io/getting-started/quick-start/%22Hugo%22&#34;&gt;Hugo&lt;/a&gt; and &lt;a href=&#34;https://themes.gohugo.io/gohugo-theme-ananke/&#34;&gt;Ananke&lt;/a&gt; to set up.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
