<?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 richa mishra on Medium]]></title>
        <description><![CDATA[Stories by richa mishra on Medium]]></description>
        <link>https://medium.com/@richa.mishr01?source=rss-35422f3f7468------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1t7ubVbShSsS5lXr.jpg</url>
            <title>Stories by richa mishra on Medium</title>
            <link>https://medium.com/@richa.mishr01?source=rss-35422f3f7468------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:26:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@richa.mishr01/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[Who Pays When Your AI Agent Gets Scammed?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@richa.mishr01/who-pays-when-your-ai-agent-gets-scammed-6924f058f8ce?source=rss-35422f3f7468------2"><img src="https://cdn-images-1.medium.com/max/1536/1*pWrqzB_qZJTikW6Z4giwyw.png" width="1536"></a></p><p class="medium-feed-snippet">Imagine you&#x2019;ve asked your personal assistant agent to buy you a pair of running shoes. It finds a merchant, compares a few options, and&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@richa.mishr01/who-pays-when-your-ai-agent-gets-scammed-6924f058f8ce?source=rss-35422f3f7468------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@richa.mishr01/who-pays-when-your-ai-agent-gets-scammed-6924f058f8ce?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/6924f058f8ce</guid>
            <category><![CDATA[agentic-payment]]></category>
            <category><![CDATA[agentic-commerce]]></category>
            <category><![CDATA[agent-pay]]></category>
            <category><![CDATA[ai-agent-security]]></category>
            <category><![CDATA[agent-protocol]]></category>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 14:03:39 GMT</pubDate>
            <atom:updated>2026-09-11T09:51:11.857Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Vibe Coding Showdown: Manus vs Lovable]]></title>
            <link>https://medium.com/@richa.mishr01/vibe-coding-showdown-manus-vs-lovable-2928474c4f1f?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/2928474c4f1f</guid>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Sat, 14 Feb 2026 18:37:16 GMT</pubDate>
            <atom:updated>2026-02-14T18:37:16.069Z</atom:updated>
            <content:encoded><![CDATA[<p>Prototyping has never been this fast and easy like today in the age of AI. Honestly, it feels illegal how quickly you can go from idea → working product now. There are so many AI-powered tools available, and of course, curiosity got the better of me. So I decided to try two tools for vibe coding and rapid prototyping: <strong>Manus</strong> and <strong>Lovable</strong>.</p><p>Here’s the quick context before I dive in:</p><p><strong>Manus</strong> is fundamentally powered by Anthropic’s <strong>Claude 3.7 Sonnet</strong>.</p><p>L<strong>ovable</strong> orchestrates multiple LLMs. Their main models are also from Anthropic and Google (Gemini), and the platform integrates with OpenAI’s GPT-4o and Groq as well.</p><p>So basically… same brains, different personalities.</p><h3>My Experiment</h3><p>I prompted both tools to create an <strong>AI-powered language learning app</strong>.<br> Reason? If I’m building it, I would like to use it myself for my daily German learning as well (productivity + selfishness = perfect combo 😉).</p><h3>Lovable</h3><p>When I prompted Lovable, it didn’t immediately start coding like an overexcited intern.</p><p>Instead… it created a one-page PRD/plan and asked for my approval.</p><p>AI asking <em>my</em> approval? Ego officially boosted. Already loved it. 😂</p><p>But on a serious note, that feedback loop is already a sign of a well-designed platform. It felt structured. Intentional. Collaborative.</p><h3>UI</h3><p>Better. Clean. Modern. Looked like something I would actually ship.</p><h3>Usability</h3><p>Very easy. I could publish the app instantly and share the URL with colleagues and friends for feedback and validation. No friction. No “download this”, no “enable developer mode”. Just link → open → test.</p><p>For validation and quick iteration? Huge win.</p><h3>Maintainability</h3><p>Better.</p><p>Unfortunately, my daily free limit got exceeded before I could experiment more (AI tools are generous… until they are not 😅). But I <em>could</em> peek into the CSS file — and it looked clean.</p><p>Perks of being a developer… you sneak into the code yourself 😉</p><h3>Manus</h3><p>Now Manus had a completely different personality.</p><p>I prompted it… and it immediately started coding. No approval. No PRD. No validation. Just pure “I got this” energy.</p><p>Confidence level: 100%. 😅<br> Alignment level: questionable.</p><p>I kept iterating that the sign-up page wasn’t working. It insisted it was already there. And Bingo my credit limit exceeded here as well. So couldn’t try further.</p><p>Although I clearly said “responsive web app,” it created a mobile app. If you don’t have a developer account to publish it, you need a simulator to run it. That means it doesn’t work out of the box if you want to validate it quickly with users.</p><p>And if your goal is vibe coding and testing ideas fast… that’s friction.</p><h3>UI</h3><p>Basic. Okay for prototyping. Not exciting.</p><h3>Usability</h3><p>Limited. I couldn’t properly test it without installing a simulator app and running it in the developer mode.</p><p>For non-technical validation? Not ideal.</p><h3>Maintainability</h3><p>Okay-ish.</p><p>When I asked to change the button color, it went through multiple pages and updated everything manually. That’s… not how CSS is supposed to work. Ideally, that should be controlled from one centralized style file.</p><p>Again, developer brain couldn’t ignore this.</p><p>Then my credits expired before I could improve it further. AI tools: “Build the future!”</p><h3>Final Thoughts (for now)</h3><p>AI tools are great!!<br>Also AI tools: “Upgrade to continue.” 😄</p><p>For this round, <strong>Lovable is a clear win with better usability and validation flow</strong>.</p><p>No wonder Lovable is… well… lovable 😊</p><p>If anyone is interested in trying out my AI-powered language learning app (especially if you’re learning German like me), feel free to reach out. I’d love feedback, testers, critics, cheerleaders… all welcome 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2928474c4f1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring in Distributed Systems]]></title>
            <link>https://medium.com/@richa.mishr01/monitoring-in-distributed-systems-1f7e8435ab81?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f7e8435ab81</guid>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 09:50:44 GMT</pubDate>
            <atom:updated>2025-01-04T09:50:44.597Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVf7CzRGYO8gUAKUFCw3Uw.jpeg" /></figure><p>Distributed systems have become increasingly prevalent in today’s IT landscape in business due to their scalability and efficiency. However, they also present challenges, particularly in monitoring and maintaining data consistency. Effective monitoring is crucial to ensure that the various components of distributed systems operate smoothly, efficiently, and reliably.</p><p>End-to-end monitoring is especially critical in distributed systems where the business stakes are high, such as in financial transactions. When transactions are lost between systems, it can result in significant monetary losses. There could be different ways of monitoring concerning security, performance, compliance and feature usages. But my focus in this article is mainly on system health monitoring and data consistency for end-to-end monitoring.</p><h3>Key Practices for End-to-End Monitoring</h3><ol><li><strong>Basic Availability Checks<br></strong>Perform basic availability checks for all systems involved. This serves as the foundation for system health monitoring, ensuring that all components are operational.</li><li><strong>Automated Alerts and Notifications<br></strong>Set up automated alerts for transaction failures to identify issues proactively. Things that you need to consider while setting alerts are:</li></ol><p><strong>Alert Rule : </strong>Define trigger points, such as when failure rates exceed a specified threshold within a predefined time frame.</p><p><strong>Notification Recipients</strong>: Determine who should receive the alerts and specify the actions to be taken, such as creating an incident ticket or notifying the development team. Normally, it’s the operation team that receives the notification and then they analyze and contact the right team.</p><p><strong>Benefits</strong>: Automated alerts help identify and address issues before they escalate, reducing the likelihood of customer complaints or merchant escalations.</p><p><strong>Tip</strong>: It is important to improve error handling first so that we can specify based on the error code or error messages for which alerts need to be set up</p><p><strong>3. Transaction Tracking Mechanism<br></strong>Implement a mechanism to assign unique identifiers to transactions. Ensure these identifiers remain consistent across all systems involved.</p><p><strong>Benefits</strong>: Unique identifiers facilitate tracking and debugging, making it easier to pinpoint where transactions are lost.</p><p><strong>4. Centralized Monitoring Dashboard<br></strong>Create a centralized dashboard that aggregates transaction data from different systems, providing a real-time overview of transaction statuses.</p><p><strong>Benefits</strong>:<br>This enables operations teams to quickly identify where transactions are lost. <br>It also provides immediate insights into system bottlenecks, helping to address issues more effectively.</p><p><strong>4. Daily Reconciliation Reports<br></strong>For the data consistency monitoring, it is also advisable to generate reports comparing transaction counts between systems to highlight discrepancies.</p><p><strong>Benefits</strong>:<br>This ensures all transactions are accounted for.<br>Assists in issue resolution and provides documentation for audits.</p><h3>Tailoring Monitoring Solutions</h3><p>There is no universal solution for monitoring that fits all scenarios. The approach depends on the specific business requirements, the software systems in use, and the applications being monitored. Monitoring is often not prioritized in favor of developing new features, but it is equally important. Reliable monitoring ensures system stability, enhances user confidence, and minimizes downtime.</p><p>In conclusion, end-to-end monitoring should be viewed as an integral part of system management. By implementing robust monitoring practices, businesses can ensure the reliability and efficiency of their distributed systems, safeguarding against potential losses and maintaining customer trust.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f7e8435ab81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Customer Lifetime Value through Buy Till You Die model and the importance of…]]></title>
            <link>https://medium.com/@richa.mishr01/predicting-customer-lifetime-value-through-buy-till-you-die-model-and-the-importance-of-f380af435dca?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/f380af435dca</guid>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 13:17:43 GMT</pubDate>
            <atom:updated>2020-04-17T13:17:43.375Z</atom:updated>
            <content:encoded><![CDATA[<h3>Predicting Customer Lifetime Value through Buy Till You Die model and the importance of segmentation.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*61AFp1r--WYfvZ3ByhUvhQ.png" /><figcaption>source: <a href="http://supermarketnews.co.nz/grocery-e-commerce-sales-growth-set-to-eclipse-offline-within-the-next-5-years/">http://supermarketnews.co.nz/grocery-e-commerce-sales-growth-set-to-eclipse-offline-within-the-next-5-years/</a></figcaption></figure><p>In a customer-centric business model, the key aspect of the strategy is to forecast customer’s behavior in the future. There are many business questions whose answers we try to seek through different customer metrics. For example, what is the maximum amount we can spend to acquire a customer? How many purchases a customer will make before churning? What is the expected time frame till he is alive?</p><p>Many sophisticated statistical models are used to answer these questions. The common metric used in all customer-centric firms is called Customer Lifetime Value(CLV). The ability to predict customer’s purchase behavior in the future helps companies to act accordingly through different advertising modes. There are mainly two types of settings in a company. Contractual and non-contractual setting. The contractual setting is a subscription-based model, in which it is very easy to determine customer behavior because the customer informs the company beforehand if he is going to end the subscription next month onwards. (Well this is not the complete picture; we require retention rate and discount factor to calculate customer life-time value in future for a contractual setting also.) While in a non-contractual setting, we need predictive modeling to know if a customer is going to make transactions in the future or not.</p><p>“Buy till you die” (abbreviated as BTYD) model captures the non-contractual customer’s purchasing behavior based on the transaction frequency and when was the last time he made the transaction (also known as recency). It calculates customer life-time value using Bayesian probability concepts. CLV is the present value of the future cash flows associated with the customer. It is a forward-looking concept and should not be confused with historical customer profitability. The rationale behind using the probability model is that even if we know the variables like marketing, personal and situational yet we embrace the randomness (or stochastic) nature of the outcome.</p><p>The formula for expected CLV,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*qIC5RcwcoknjG-bpqO30Zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*r7HeGkQewkHbjKyEewCx7A.png" /><figcaption>source: (Fader &amp; Hardie, 2009)</figcaption></figure><p>Illustrative example to explain how the model works :</p><ol><li>Customer B and C have made four purchases in the interval(0, T] but customer C has been inactive for a long time. While customer B has recently made a purchase (considering T is the current time). As a result, we would expect B to have more transactions in the future.</li></ol><p>2. Customer A has made only when the purchase and last transaction is done by A was at the same time as that of C. Customer A can be considered as a light buyer and thus the expectation of A being alive at time T is greater than that of C.</p><p>3. The last purchase made by the customer B and D were at the same time. But since the customer D made just two purchases in the interval (0, T], we would expect fewer purchases from customer D in the future.</p><p>While CLV is very important information for a company to make business decisions. If it is not correctly calculated, it may lead to some bad decisions in the company. It has been observed that the BTYD model makes some extreme predictions of customer’s dying probability. (While simulating the model in python using lifetimes library, even I observed that customers who have not made any repeated purchase has a 100% likelihood that they are still alive. However, it is not true in the real world.) This is where the BTYD model has its limitations. The predictions are sometimes so extreme that even after thousands of years model will show these customers as still alive. The explanation for such extreme predictions could be first, we are looking into data for a certain time interval. Secondly, the customer base likely to contain many segments. At least the two common segments of the customer base are those who are frequent buyers and those who buy occasionally. This brings our attention to incorporate the heterogeneity distribution of customers in the model.</p><p>These segmentations of customer base out of their latent characteristics has not only improved lifetime predictions but also substantially increases the explanatory power of these models. Additionally, if the segmentation is done effectively, it allows the company to identify more profitable customers and accordingly they can offer customized products/services for each segment. Moreover, even for the new customer if they can correctly identify to which segment does he belongs, they can predict the purchasing behavior of the new customer.</p><p>Hence, by simple act customer segmentation can give a clearer picture of overall customer equity to a company.</p><p>References:</p><ol><li><a href="http://www.brucehardie.com/talks/ho_cba_tut_art_13.pdf">http://www.brucehardie.com/talks/ho_cba_tut_art_13.pdf</a></li><li>Fader, P. S. &amp; Hardie, B. G., 2009. Probability Models for Customer-Base Analysis. <em>Journal of Interactive Marketing, </em>Volume 23, pp. 61–69.</li><li><a href="https://repub.eur.nl/pub/51244/ers-2014-006-lis.pdf">https://repub.eur.nl/pub/51244/ers-2014-006-lis.pdf</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f380af435dca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prisoner’s Dilemma of Music label companies]]></title>
            <link>https://medium.com/@richa.mishr01/prisoners-dilemma-of-music-label-companies-c4dcc41d1f59?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4dcc41d1f59</guid>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Thu, 09 Apr 2020 15:11:01 GMT</pubDate>
            <atom:updated>2020-04-09T15:11:01.869Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was a part of my MBA’s mini term paper Advanced Strategic Management subject. It is about how music labels are sacrificing their own profits (which they could have achieved if they had their own music streaming platforms). There is a fear of losing market share which compels big music labels such as Warner Music Group(WMG), Sony Music Entertainment(SME), Universal Music Group(UMG) to stick to online streaming channels like Spotify for distribution. The article is an attempt to explain the above scenario with the help of the Prisoner’s dilemma.</p><p>The Music Industry has always seen a disruption ever since the beginning of the internet world. Despite having so many artists and the whole world being its consumer, this industry has always been dominated by few players be it music label companies or music streaming channels. <br>Streaming market share of Universal in 2017 was 33.74% while Sony has 25% and Warner has 21.74%. Despite having such a huge market share major portion of the profit is being taken away by Spotify, who enjoys 36% of music streaming subscribers worldwide. (source: Statista) Spotify pays around 50% of the revenue generated by each stream to record labels (source: NYTimes). So, technically if the music labels would have their own online streaming channel, they would not have to share the revenue by anyone. So why music labels are not crushing Spotify and launching their own online platform for distribution.</p><p>This is a good example of the <strong>prisoner’s dilemma</strong>. <br>Spotify has become so big because it has a huge number of subscribers. And to start in-house online distribution would mean losing Spotify’s subscribers and to gain such a big number of subscribers would obviously take time. Hence, music labels have two choices either to stay with Spotify and enjoy benefits of market share or leave Spotify and lose market share but gain profit (eventually). In terms of profit and market share, payoffs would be gain in profit or gain in the market share of these labels. <br>Hence, there are four possible outcomes. These are explained by an example of Universal versus others. (Instead of Universal there could be any other music label versus others.)<br> <br>1. If Universal leaves Spotify and other music labels have two options either to stay or to leave Spotify. If they leave, all will have a gain in their profit. However, if they stay with Spotify, they will have a gain in market share. Considering gain in market share has a better payoff than profit, other music labels will stay with Spotify.</p><p>2. If Universal stays with Spotify. Again, other music labels have two options either to stay or to leave Spotify. If they leave, Universal will have all the market share while other music labels will enjoy gains in profit. While if they stay with Spotify, all the music labels would enjoy market share. And on the same argument as above, other music labels will decide to stay with Spotify to have a better payoff. <br>Hence, other music labels will stay with Spotify irrespective of Universal’s strategy. Thus, staying with Spotify is going to be a dominant strategy by other music labels. <br>Now let’s consider Universal’s options.</p><p>3. If other music labels stay with Spotify and Universal has two options either to stay or leave Spotify. A similar argument as above can be made and considering the gain in market share has a better payoff than profit, Universal will stay with Spotify.</p><p>4. If other music labels leave Spotify and Universal would then decide to stay with Spotify as it will enjoy alone the whole market share of the subscribers. <br>Again, it can be seen that Universal will stay with Spotify irrespective of other music label’s strategies. <br>Eventually, staying with Spotify by all the music labels is a Nash equilibrium where both the parties are playing safe by staying with Spotify. Figure illustrates the above argument through the Payoff matrix and Nash equilibrium.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*JDRuF2-1A2AWZX5GP0zMog.png" /></figure><p><strong>Conclusion : </strong>Every music label is thinking the same and since collusion is not allowed in business there is a lack of trust among them and they can’t discuss their strategy with others. All of them are going to stick with Spotify for the online streaming of their music and not making the profit as much as they could have, had they started their own online distribution platform. As a consequence, Spotify is the big winner of this prisoner’s dilemma.</p><p>References</p><p>Statista available at:<a href="https://www.statista.com/statistics/653926/music-streaming-service-subscribershare/">https://www.statista.com/statistics/653926/music-streaming-service-subscribershare/</a> <br>NYTimes, “A New Spotify Initiative Makes the Big Record Labels Nervous”, available at:<a href="https://www.nytimes.com/2018/09/06/business/media/spotify-music-industry-record-labels.html">https://www.nytimes.com/2018/09/06/business/media/spotify-music-industry-record-labels.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4dcc41d1f59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystified Monte Carlo Simulation]]></title>
            <link>https://medium.com/@richa.mishr01/demystified-monte-carlo-simulation-e47ad8fe2581?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/e47ad8fe2581</guid>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Tue, 07 Apr 2020 10:50:55 GMT</pubDate>
            <atom:updated>2020-04-07T10:50:55.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O6wVLRbfPa3QBs_Dszy6WA.png" /><figcaption>source: <a href="https://www.caesarsgames.com/2017/10/27/most-popular-casino-games-in-las-vegas/">https://www.caesarsgames.com/2017/10/27/most-popular-casino-games-in-las-vegas/</a></figcaption></figure><p>There are so many uncertainties in business. And we need a risk analysis for these uncertainties. If we talk about uncertainties. There are two types of uncertainties. Firstly, the probability (uncertainties) of outcomes where everything is uncertain. For example, sometimes we don’t know if the new product or service launched by the company is going to be successful or not. Secondly, there is the uncertainty of an outcome that can be estimated. These uncertainties can be measured in terms of probability. These uncertainties can be in the form of demand for any product, the number of passengers boarding a flight, profit in the company, or profit made by a stock in the stock market. Hence, we need models to be able to capture these variabilities (uncertainties). Generally, historical values of the uncertain variables are used to deduce patterns and then they help in assessing risks.</p><p>In the entrepreneur lectures, we have been taught to do the worst case, best case and the most likelihood (estimated or sometimes also called an average of all the possibilities )case analysis. But in the real world, we know that there can be N number of possibilities between the worst and best-case scenarios. The most popular way to get the values of all the possible outcomes between those worst and best-case scenarios is through Monte Carlo Simulation.</p><p>So, what is the Monte Carlo Simulation?</p><p>Well, we all know that the idea of this simulation came from the famous Casino game. I will try to focus on aspects that are important from the analytics perspective.</p><p><strong>Monte Carlo Simulation:</strong></p><p>It is a method of estimating values of unknown quantity using inferential statistics. By inferential statistics, we mean all the possible outcomes. And it could be thousands or millions of possible outcomes which can be referred to in a simple language as a population of outcomes. From that population, we take the random sample. The assumption behind the random sample is that random sample exhibits the same properties that of the population.</p><p>With that random sample as an input variable, the distribution of possible outcomes is drawn. Then we can have a range of values as a possible outcome. So, we have input(uncertain) variables and we have an output variable (mostly in terms of profit or revenue) which we need to estimate. For the Monte Carlo Simulation to work, we need to have some assumptions about the distributions or behaviors of these input variables. These assumptions are mostly based on historical data.</p><p>For example, in the case of a number of passengers boarding a flight depends on the input variable i.e. the proportion of passengers showing up at the time of boarding. And there are only two possible outcomes “yes” or “no”. Hence, the show-up rate follows Bernoulli(or Binomial) distribution. While the price of a stock may be assumed as the random walk and thus will have a normal distribution. Historical data may have some biases or may be influenced by some other factors. Instead of using historical data as it is, it is important to get the best-fitted frequency distribution of historical data which could be assumed to be free from all the biases and will have even those possible (input variable)outcomes which didn’t happen in the past but may happen in the future. Another assumption that is made in a model with two or more than two input variables is that these input variables are independent variables. However, when the input variables are not independent, we need to incorporate correlation coefficients too in the simulation model.</p><p>Having laid the foundation of the Monte Carlo Simulation, I tried to simulate a simple example of predicting the price of the stock in the python.</p><p>The price of a stock over a year looks like a random walk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*bGDQvR-gH3rLWfcrm8g8HA.png" /><figcaption>Figure 1. Price of a stock over a year</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*fRDxfU0p0bSjmofFRffU6Q.png" /><figcaption>Figure 2. Frequency distribution of profit over a year</figcaption></figure><p>In this example, the price of the stock is our input variable and output will be profit being made by the stock. Hence, the distribution of profit gained over a year looks like figure 2.</p><p>The result we get is only one possible outcome. As the monte Carlo simulation says, we need to run the code for all the possible outcomes. For all the possible outcomes, first, we need to understand the distribution of price. If we assume that the price belongs to a random walk process, we can have a normal distribution with an average(mean) value of the price and the standard deviation of the price (which gives the variability or volatility of the stock price). Now that we have a frequency distribution of the stock price and there is only one input variable so we don’t need to check correlation, we can run the model thousand or ten thousand times to get all the possible outcomes of the price. And this gives thousands of options of simulated price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*Wg4WEF1Mxx9NdQA3g2Gwcg.png" /></figure><p>When we look into the distribution of all the possible prices generated through the simulation. We can have a range of prices from less than 100 to even greater than 900. But we can confidently say that there is 5% chance that the price of the stock would go below 151 and 5% chance that it will go above 592. And the average price would linger around 313.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*3ALS8ZL7NNmyMVPl7CaliQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*P6ERQXYXyW77o4m-SBYlrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*1g97G93iWmIVHSOYzTpI3w.png" /><figcaption>Figure 3. Frequency distribution of stock price simulated for 1000 outcomes</figcaption></figure><p>Now that we have the confidence interval, we can decide whether to take the risk and go ahead with the decision of investing in these stocks. This is the main purpose of Monte Carlo simulation to give the confidence interval with the range of values and assessing the risk involved in the decision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e47ad8fe2581" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anomaly detection in seasonal time series where anomalies coincide with seasonal peaks]]></title>
            <link>https://medium.com/@richa.mishr01/anomaly-detection-in-seasonal-time-series-where-anomalies-coincide-with-seasonal-peaks-9859a6a6b8ba?source=rss-35422f3f7468------2</link>
            <guid isPermaLink="false">https://medium.com/p/9859a6a6b8ba</guid>
            <dc:creator><![CDATA[richa mishra]]></dc:creator>
            <pubDate>Fri, 06 Mar 2020 17:26:12 GMT</pubDate>
            <atom:updated>2020-03-06T17:26:12.004Z</atom:updated>
            <content:encoded><![CDATA[<p>Anomaly detection in time series data is always an interesting topic among scientists and engineers who deal with forecasting.</p><p>While there are many ways to deal with outliers in time series data.</p><p>Some common methods used in detecting outliers in a time series are following</p><p>1. The rolling average window of the time series data is calculated. Then an individual z-score is calculated for every point. And then a data point which is more than 3 standard deviations away from a rolling average are considered as outliers.</p><p>2. In unsupervised machine learning, there are other classification methods such as SVM or KNN methods which can be used to cluster outliers in a separate cluster. In these methods, the algorithm infers the properties of normal points and then from these properties it tries to check whether a point is normal or not.</p><p>3. Isolation Forest is another unsupervised machine learning algorithm which instead of looking for normal points, isolates the unusual or anomaly from the normal points by focusing on uncommon properties of anomalies.</p><p>This article discusses outlier detection in seasonal time series where there are peaks at regular intervals of time and there are abnormal peaks also coinciding with seasonal peaks. Hence, in a way, the outliers sabotage themselves with seasonal peaks. In such cases, even sophisticated machine learning methods like Isolation forests get confused between normal seasonal peaks and abnormal seasonal peaks.</p><p>A daily time series when trained with Isolation Forest detected many anomalies. But closely looking into data, it was observed that these are peaks occur at every month-end. That means they are periodic in nature and may not be real abnormal points in time series. Anomaly detection in time series using IF in figure 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPOm1qH04ySL4b4-IPeRzA.png" /></figure><p>Here, we will look at anomaly detection using STL (Seasonal Trend decomposition using Loess) method. As we know, any time series can be decomposed into seasonal, trend and residual components. And once the trend and seasonal component has been separated from the time series, the residuals left can be used to identify outliers as these outliers will purely be part of some random fluctuations in the series.</p><p>And since we know that peaks are periodic in nature and occur every 4 weeks. It would be nice to aggregate the time series in a weekly basis so that we can have a set pattern for seasonality in the time series. The weekly time series looks like in figure 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*cQqgd99OU5HBsHrMQWRWcw.png" /></figure><p>When the time series is decomposed into trend seasonality using STL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*9sCqJP7iLCSZpVZImCvXgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*btlVyVktPsTmAboIA5wp_A.png" /></figure><p>Now we need to train a predictive model with these residuals to predict their values. A point to be noted here is that these residuals are free of any trend and seasonality , hence, simple Arima would also work. I used the auto_arima function of the pyramid arima library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*54g5uy24PuPfdx7ABAd3Hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*_mbtRVyQtyBWc6Q1WP5-5Q.png" /></figure><p>Now, looking into the distribution of errors (which is actually the difference between the predicted value and actual value) and we can have a confidence interval of 3 standard deviations in the distribution of the errors. And this 3 standard deviations gives us the threshold values for the errors. If any error point data point is lying outside the threshold, then those data points can be considered as potential outliers in the time series data with seasonal trend and seasonality.</p><p>Which correctly gives us real outliers in the series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*2LSLNCwCOmaw_1gKS30Liw.png" /></figure><p>References:</p><p>Lee, S. &amp; Kim, H. K., 2018. ADSaS: Comprehensive Real-time Anomaly Detection System. <em>Information Security Applications — 19th International Conference, WISA 2018, </em>pp. 29–41.</p><p><a href="https://stackoverflow.com/questions/57069892/how-to-detect-anomaly-in-a-time-series-dataspecifically-with-trend-and-seasona">https://stackoverflow.com/questions/57069892/how-to-detect-anomaly-in-a-time-series-dataspecifically-with-trend-and-seasona</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9859a6a6b8ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>