<?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 Eryk Faracik on Medium]]></title>
        <description><![CDATA[Stories by Eryk Faracik on Medium]]></description>
        <link>https://medium.com/@eryk.faracik?source=rss-c22f9c750ea2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zJyccbus9Z1t8Gs21dR6CA.jpeg</url>
            <title>Stories by Eryk Faracik on Medium</title>
            <link>https://medium.com/@eryk.faracik?source=rss-c22f9c750ea2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:30:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eryk.faracik/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[5 Powerful Quotes That Changed My Perspective (And Might Change Yours Too)]]></title>
            <link>https://medium.com/@eryk.faracik/5-powerful-quotes-that-changed-my-perspective-and-might-change-yours-too-7f7d9d8efb6c?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f7d9d8efb6c</guid>
            <category><![CDATA[perspective]]></category>
            <category><![CDATA[mindset]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[thoughts]]></category>
            <category><![CDATA[motivation]]></category>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 18:22:26 GMT</pubDate>
            <atom:updated>2026-01-05T22:24:39.926Z</atom:updated>
            <content:encoded><![CDATA[<h4>Five quotes that shaped how I think and see life.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvvMhwRNDvGs8i-puo3KfA.jpeg" /></figure><p>The key to achieving success is <strong>consistency</strong>, not <strong>motivation</strong>. However, we all need a little motivation sometimes, especially when things get tough.</p><p>One of my ways to boost motivation is listening to motivational videos on YouTube or Spotify, or by reading articles and books about life and self-improvement.</p><p>The five quotes I will share come from different sources and people. They’re not just about growth and studying but also about life and how to approach it.</p><h3>1.</h3><blockquote><em>He who says he can and he who says he can’t are both usually right. — </em><strong><em>Confucius</em></strong></blockquote><p>The first quote is from Confucius. The first time I read it, it didn’t seem as powerful as it does now. It’s short, with a simple message, and it’s so true.</p><p>When we’re planning, for example, to pass an exam, telling ourselves that we <em>can</em> do it instead of thinking <em>we can’t</em> doesn’t hurt anyone, but for us, it can be incredibly encouraging.</p><p>Even if you’re struggling with some exam problems or feeling tired, believing in yourself can often make a difference, helping you succeed.</p><p>Assuming from the start that you can’t do something you truly want, is like placing limits on yourself. Those limits exist (sometimes) only in your mind. I strongly believe that if we want to achieve something, believing in ourselves is a crucial first step.</p><p>Of course, we still need to put in the effort — whether it’s studying, working, or exercising — but it all starts with the confidence that <em>you can</em>!</p><h3>2.</h3><blockquote><em>If you can be in a bad mood for no reason, you might as well be in a good mood for no reason. — </em><strong><em>Alex Hormozi</em></strong></blockquote><p><a href="https://www.youtube.com/c/alexhormozi">Alex Hormozi</a> isn’t a philosopher like Confucius was. He’s an entrepreneur. I follow him on many social media platforms, and he inspires me to take action.</p><p>The quote I’m sharing below was eye-opening for me, especially for my younger self, who often used his mood as an excuse not to go to the gym, skip university classes, or avoid studying for an important exam.</p><p>Sometimes, we wake up feeling bad or tired and assume the whole day will be awful. But that’s false — it only turns out awful if we let our mood dictate our plans and stop us from taking action to make the day better.</p><p>Feelings are powerful tools that can guide us in understanding whether certain people, actions, or events are good for us. Recognizing and reflecting on them helps us better understand ourselves and our decisions.</p><p>However, there are times when there’s no real reason to feel so bad, so why not try to find the positives and get the work done anyway?</p><h3>3.</h3><blockquote><em>There is nothing in this world that can hurt you more than your thoughts. And there is nothing in this world that can heal you as much as your thoughts. — </em><strong><em>Unknown</em></strong></blockquote><p>Do you sometimes think negatively about yourself? Do you have catastrophic thoughts about what could happen next? Or maybe you overthink all the possible negative scenarios of your decisions? I’ve been there. Do I want to go back to that mindset? Not.</p><p>Instead, I choose to think positively about myself, focus on the things I can control, and, while making decisions, acknowledge the risks but focus more on the possible positive outcomes.</p><p>The thoughts in our heads will always be there. But our minds are ours to shape, and recognizing that we have full control over how we think is a game-changer.</p><p>It’s not always easy, but it is possible to work on changing your thought patterns, confronting your fears, and looking at things from a different perspective. When you do, you’ll feel more at peace and much calmer.</p><h3>4.</h3><blockquote><em>Spend so much time on self-improvement that you have no time to criticize others. — </em><strong><em>Jay Sean</em></strong></blockquote><p>Let’s look at this from another perspective. In our lives, we encounter many people. Some are close, like family and friends. Others we know from school, college, or work. Some we don’t know personally, but they still know about us. Each of these people will have different opinions and visions of you and your life. Why is that?</p><p>Because you don’t share the same information with everyone. You might have met them at different stages of life — at age 12 or 20 — you may have different political views, or you simply don’t talk to them as much as you do with others. But should any of these opinions define you?</p><p>Of course not, because the only person who truly knows you best is <em>you</em>.</p><p>For me, the goal is to be better than the person I was in the past and to achieve my goals for the future. Competing with others is rarely the best motivator, and the same goes for criticizing others — especially people you don’t know well.</p><p>If each of us focuses on improving ourselves and shares kindness with those around us, I believe the world would be a much better place to live.</p><h3>5.</h3><blockquote><em>So, maybe it’s not that you’ve been cheated out of an unlimited supply of time; maybe it’s almost incomprehensibly miraculous to have been granted any time at all. — </em><strong><em>Oliver Burkeman</em></strong></blockquote><p>The last quote comes from one of my favorite books, <a href="https://www.oliverburkeman.com/books"><em>Four Thousand Weeks</em></a> by Oliver Burkeman. Many might say that the ideas he writes about are cliché, simple, or things we already know. But is that really true?</p><p>For me, it wasn’t. He writes about shifting our perspective on life — how short it really is — and how accepting that we will eventually die can actually help us live better lives.</p><p>I remember many moments when I feared mortality. The thought that one day would be my last — my last meal, my last workout, my last everything — felt unfair and deeply sad. I couldn’t help but wonder, <em>Why does it have to be this way?</em></p><p>But then, I started thinking differently. The fact that I was born in this century, or born at all, feels nothing short of miraculous. The reality that life has an end actually brings a sense of meaning to our daily actions.</p><p>Every action or relationship becomes more significant. You have limited time, and yet you choose to do something or spend time with someone. That choice — to share a part of your finite time — makes those moments and connections all the more meaningful.</p><p>In the end, each of us has a different background, and different words inspire us to study, grow, and achieve our goals.</p><p>But maybe some of you will agree that some quotes are nearly universal, like this one from Michael Scott…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*6f9FBh0QPj4OOEaVnmuzbA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f7d9d8efb6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Truth About Actuarial Exams No One Talks About]]></title>
            <link>https://medium.com/@eryk.faracik/the-truth-about-actuarial-exams-no-one-talks-about-d137c575c88e?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d137c575c88e</guid>
            <category><![CDATA[actuarial-science]]></category>
            <category><![CDATA[self-care]]></category>
            <category><![CDATA[actuarial]]></category>
            <category><![CDATA[actuarial-exams]]></category>
            <category><![CDATA[self-love]]></category>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 09:43:28 GMT</pubDate>
            <atom:updated>2025-11-11T09:47:42.919Z</atom:updated>
            <content:encoded><![CDATA[<h4>…that is, the feeling of losing yourself and seeing no progress after the exam.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*As49DjHeLNG5Qrf3HAZWRQ.jpeg" /></figure><p>I’ve just finished another marathon of actuarial exam study sessions. For a couple of months, my life was reduced to formulas, practice problems, and repetition. Now that it’s over, there’s silence. And honestly, I don’t know what to do with it.</p><h3>The Hidden Side of Preparation</h3><p>Everyone talks about time management and study plans (<em>guilty</em>). But no one talks about what happens when studying becomes your identity. When you rest, you feel lazy.</p><blockquote><em>When you stop, you feel lost.</em></blockquote><p>In July this year, I made myself a study plan to pass not one, but a few actuarial exams and courses.</p><p>I like to learn new things, and I am truly passionate about actuarial science. Let’s say studying for and achieving new actuarial milestones gives me direction and motivation.</p><p>So, I made a plan and studied before and after work. I studied on weekends. I still wanted to manage my time so that I could spend quality time with my close ones, exercise, eat well, and sleep.</p><p>And it produced results. In August, I passed the CAS DISC IA exam. Then, in October, I passed three Polish actuarial exams and took the MAS-I exam (the results haven’t been published yet).</p><p>But… after that, reality was a little <strong><em>different</em></strong>.</p><h3>My Realization</h3><p>The truth is, exams shape us, but they shouldn’t define us. I realized that learning doesn’t end when the exam is over — it just changes form.</p><blockquote>Gaining more actuarial credentials doesn’t necessarily make you a better person or even a better actuary.</blockquote><p>Therefore, I’m learning how to rest properly. I’m managing my health and well-being. I will still be preparing for actuarial exams, but with more consciousness.</p><h3>Final Thoughts</h3><p>If you’re feeling lost after an exam, you’re not alone! Maybe this quiet time isn’t a setback — maybe it’s space to rediscover who you are beyond the next syllabus.</p><p>Sit down in your room. Look at your life — what you’d like to do — and do it. Take care of yourself and be kind to yourself.</p><p>A couple of weeks, or even months, of break from study marathons can recalibrate you, show what’s really important, and remind you that there’s more in this world than passing another exam.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d137c575c88e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write a Function in R with Me]]></title>
            <link>https://medium.com/r-evolution/write-a-function-in-r-with-me-9bd31376327a?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bd31376327a</guid>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Fri, 30 May 2025 17:03:38 GMT</pubDate>
            <atom:updated>2025-05-30T17:06:38.515Z</atom:updated>
            <content:encoded><![CDATA[<h4>Step-by-step guide on how to write your function in R.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmFOgpVBMmIQBYmm-NjnSw.jpeg" /></figure><p>While working with data in R, sometimes I need to create my functions to speed up the calculations. I know that at the beginning, writing your functions may seem difficult. Therefore, here is by step-by-step guide on how to do it.</p><h3>Step 1: Structure of a Function in R</h3><p>The structure of the R function looks like this:</p><pre>my_function &lt;- function(arg1, arg2, ...) {<br>  # body of the function<br>  # computations and operations<br>  return(result)<br>}</pre><p>where <strong>arg1, arg2</strong>, and so on are arguments, e.g., .</p><p>Then we open a <strong>{</strong> and write formulas, what our function does.</p><p>In <strong>return(result)</strong>, we specify an object that will be the output of this function. It could be a single number, an array, or a data frame.</p><h3>Step 2: Define Your Function Name and Arguments</h3><p>Let’s create a simple function to calculate the <strong>sum of the squares</strong> of two numbers.</p><pre>sum_of_squares &lt;- function(x, y) {<br>  result &lt;- x^2 + y^2<br>  return(result)<br>}</pre><p><strong>x, y</strong> are arguments, the name of the function is <strong>sum_of_squares</strong>, and the output is the result.</p><h3>Step 3: Test the Function</h3><p>To check if your function works all right, just check if it works manually on a couple of different values.</p><p>This function is simple. However, testing more complicated functions may take a little bit longer. Then, finding and repairing its formulas may last longer, too.</p><pre># Test 1<br>sum_of_squares(3, 4)<br># Expected Output: 25<br><br># Test 2<br>sum_of_squares(-2, 5)<br># Expected Output: 29</pre><h3>Step 4: Include Error Handling</h3><p>To make your function more robust, include error checks for invalid inputs.</p><p>In our case, we want <strong>x</strong> and <strong>y</strong> to be <em>numeric</em> type.</p><pre>sum_of_squares &lt;- function(x, y) {<br>  if (!is.numeric(x) || !is.numeric(y)) {<br>    stop(&quot;Both x and y must be numeric values.&quot;)<br>  }<br>  result &lt;- x^2 + y^2<br>  return(result)<br>}</pre><p>While testing with a non-numeric argument, the function’s output should say that b<em>oth x and y must be numeric values.</em></p><h3>Conclusion</h3><p>Writing the first function in R might be a challenge.</p><p>However, when you break the process into steps, it becomes easier to understand.</p><p>Feel free to experiment with the presented formulas and create different versions of this function or a completely new one.</p><p>Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bd31376327a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/r-evolution/write-a-function-in-r-with-me-9bd31376327a">Write a Function in R with Me</a> was originally published in <a href="https://medium.com/r-evolution">R-evolution</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Combined Ratio Explained: Comparing the Two Main Formulas]]></title>
            <link>https://medium.com/@eryk.faracik/combined-ratio-explained-comparing-the-two-main-formulas-aeca4717aa9f?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeca4717aa9f</guid>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Fri, 30 May 2025 16:47:34 GMT</pubDate>
            <atom:updated>2025-05-30T16:47:34.359Z</atom:updated>
            <content:encoded><![CDATA[<h4>The combined ratio is one of the most important metrics in insurance, used to assess an insurer’s profitability and efficiency.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3rTHrOUl1fcRtO5vj-7og.jpeg" /></figure><p>Recently, I was studying materials from the <strong>CAS DISC RM</strong> online course. It focuses on <strong>risk management</strong> and the <strong>insurance industry</strong>. I learned a lot about writing different types of insurance, how insurers operate in the <strong>USA</strong>, and how to measure the <strong>financial profitability</strong> of insurance companies.</p><p>One of the key metrics used to measure an insurance company’s success in underwriting is the <strong>combined ratio</strong>.</p><p>Although I was already familiar with this ratio, my understanding has significantly improved after studying these materials.</p><p>One interesting thing I learned is that the <strong>CAS DISC RM</strong> materials present a different formula for the <strong>combined ratio</strong> compared to other online sources. While the results are similar, there are still some differences.</p><h3>What Is the Combined Ratio?</h3><p>The combined ratio is a key financial metric used in the insurance industry to evaluate underwriting performance.</p><blockquote>A combined ratio <strong>below 100% means the insurer is making an underwriting profit</strong>, while a ratio <strong>above 100% indicates an underwriting loss</strong>.</blockquote><p>It can be calculated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*o3yVqZ2BHMW_B4strhPuUw.png" /></figure><p>where <strong>incurred losses</strong> are claims payments and loss adjustment expenses, such as court fees, and <strong>underwriting expenses</strong> are administrative costs, commissions, and other operational expenses.</p><p>Earned premiums represent the revenue an insurer earns from policies during a given period.</p><p>But also, the combined ratio can be calculated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*XmnmEJW-yF2uy5_PPh1IhA.png" /></figure><p>where the loss ratio is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*2U_vtAiUgXtgv4-Pwy2Xcw.png" /></figure><p>(LAE stands for loss adjustment expenses.)</p><p>And the expense ratio is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*ST8hN8maE3nwxgVDtLMH7Q.png" /></figure><p>As you may see, the denominators differ in loss ratio and expense ratio.</p><p>Earned premiums usually are not equal to written premiums, which are the total amount of premiums an insurance company records on its books for policies issued during a specific period, <strong>regardless of whether the premium has been received in full</strong> or whether the policy period has begun.</p><p>Therefore, calculating the combined ratio using these two methods can produce different outcomes.</p><h3>Why Does It Matter?</h3><p>There are many ways combined ratio matters in insurance companies:</p><ol><li><strong>Measures underwriting profitability</strong> — A combined ratio below 100% indicates an underwriting profit, while a ratio above 100% means the insurer is losing money on underwriting alone.</li><li><strong>Evaluates operational efficiency</strong> — It shows how well an insurer manages losses and expenses relative to the premiums collected or written.</li><li><strong>Helps assess financial stability</strong> — A consistently high combined ratio may indicate wrongly priced policies, high claim costs, or excessive operational expenses, all of which can threaten an insurer’s profitability.</li><li><strong>Provides insight for decision-making</strong> — Insurers can use this metric to improve pricing, risk selection, and expense management to improve financial performance.</li><li><strong>Monitored by investors and regulators</strong> — A key metric for analysts, investors, and regulators to evaluate an insurer’s long-term financial stability and competitive position in the market.</li></ol><h3>Example</h3><p>If an insurer has:</p><ul><li><strong>$70 million</strong> in losses</li><li><strong>$5 million</strong> in loss adjustment expenses</li><li><strong>$2.5 million</strong> in underwriting expenses</li><li><strong>$200 million</strong> in premiums written</li><li><strong>$100 million</strong> in premiums earned</li></ul><p>What is the combined ratio of this insurer?</p><h3>Solution 1</h3><p>The combined ratio is the sum of incurred losses, loss adjustment expenses, and underwriting expenses divided by earned premiums. Taking values from the example, we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*d2HN5JiPx8rQ6YSYICpz4Q.png" /></figure><p>Since the ratio is <strong>below 100%</strong>, the insurer is making an underwriting profit.</p><h3>Solution 2</h3><p>The combined ratio is the sum of the loss ratio and expense ratio. Taking values from the example, we have a loss ratio equal to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*IfaCR8KW8D2SIicdDAuGmQ.png" /></figure><p>expense ratio equal to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*L6FvohIbEu1irdZ_krN9mg.png" /></figure><p>and the combined ratio, which is equal to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*EpRYpeJMRsLUo-7urVaOpg.png" /></figure><p>Since the ratio is <strong>below 100%</strong>, the insurer is making an underwriting profit.</p><blockquote>Using both methods, we see that the insight is the same, but the values are slightly different.</blockquote><h3>Summary</h3><p>The combined ratio is a simple yet highly insightful metric in the insurance industry.</p><p>There are two main methods for calculating this metric.</p><p>While they differ slightly, insurance companies should have strict guidelines on which calculation method to use, especially when dealing with large volumes of losses, expenses, and premiums.</p><p>Combined Ratio: Definition, What It Measures, Formula, Examples <strong>— </strong><a href="https://www.investopedia.com/terms/c/combinedratio.asp">https://www.investopedia.com/terms/c/combinedratio.asp</a></p><p>Understanding Combined Ratio <strong>— </strong><a href="https://insurancetrainingcenter.com/resource/understanding-combined-ratio/">https://insurancetrainingcenter.com/resource/understanding-combined-ratio/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeca4717aa9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exponential Distribution: 5 Key Properties You Should Know]]></title>
            <link>https://medium.com/@eryk.faracik/exponential-distribution-5-key-properties-you-should-know-604e500949a0?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/604e500949a0</guid>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Fri, 30 May 2025 12:57:57 GMT</pubDate>
            <atom:updated>2025-05-30T12:58:59.089Z</atom:updated>
            <content:encoded><![CDATA[<h4>The exponential distribution is a cornerstone of probability theory and has plenty of useful properties.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGy9a_NwkZC3MaH7tCVKVg.jpeg" /></figure><p>Lately, I’ve been focusing on studying for the <strong>MAS-I</strong> exam. One of the topics I’ve explored recently is the properties of the exponential distribution.</p><p>When solving exam problems in the past, I wasn’t aware of some very useful properties. If I had known them earlier, I probably could have solved those problems more quickly.</p><p>The purpose of this post is to share with you five key properties that I believe can help you with solving actuarial exam problems, especially those on probability exams.</p><h3>Exponential Distribution</h3><p>The exponential distribution describes the distance between events in a <a href="https://en.wikipedia.org/wiki/Poisson_point_process">Poisson process</a>, where events occur continuously and independently at a constant rate λ.</p><p>This distance can measure time between production errors or the length along a fabric roll. It is a special case of the <a href="https://en.wikipedia.org/wiki/Gamma_distribution">gamma distribution</a> with a shape parameter equal to 1.</p><p>Before diving into the key properties of this distribution, let’s take a quick look at its <strong>PDF</strong> and <strong>CDF</strong> functions.</p><h4>PDF and CDF</h4><p>As mentioned earlier, the exponential distribution can be expressed as a function with a constant rate λ.</p><p>This rate is derived from the Poisson distribution and represents the average number of occurrences per unit of time or space.</p><p>The exponential distribution, however, describes the distance between occurrences. A more useful parameter in this context is the average distance between occurrences, denoted as θ, where θ=1/λ.</p><p>The <strong>PDF</strong> in both cases can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*sQgN1lbUMcwASZ4vTqi4gQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*VOtdBkYLpuJhm3oU2CqdWA.png" /><figcaption><strong>Formula 1.</strong> The probability density function of the exponential distribution in two forms: for λ and θ.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*mJhksS3LJqjPp7DlB9Sx6w.png" /><figcaption>I<strong>mage 1.</strong> The probability density function (PDF) of the exponential distribution with three different λ parameter values.</figcaption></figure><p>And <strong>CDF</strong> as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*dK4mdG-2VBqHGEWzmJygqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*qXOqvWGmaFdundJ2-4Lhjg.png" /><figcaption><strong>Formula 2.</strong> The cumulative distribution function of the exponential distribution in two forms: for λ and θ.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*zaLC7eyJwr1UDoW_nPo0PQ.png" /><figcaption>I<strong>mage 2.</strong> The cumulative distribution function (CDF) of the exponential distribution with three different λ parameter values.</figcaption></figure><p><strong>In this post, I’ll present the key properties of the exponential distribution with the parameter λ.</strong></p><p>While the learning materials for the MAS-I exam use the parameter θ, many online resources, including Wikipedia, use λ to express the exponential distribution.</p><h3>5 Key Properties</h3><blockquote>In all the properties below, the random variable X follows an exponential distribution with parameter λ&gt;0.</blockquote><h4>1. Memorylessness</h4><p>A hallmark of the exponential distribution is its memoryless property:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*OX-hAdT2P3zwA7F9sn83dw.png" /></figure><p>where <strong><em>c</em></strong> is a positive constant.</p><blockquote>That means the probability of an event occurring in the future is independent of the time already elapsed.</blockquote><p>This property simplifies calculations in actuarial science, such as when deductibles are applied.</p><h4>2. Raw Moments of the Distribution</h4><p>The k-th raw moment of the exponential distribution can be calculated using:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*yS9TJcDpxRlghcuqGJY6vQ.png" /></figure><p>where <strong><em>k</em></strong> is a positive integer.</p><h4>3. Distribution of the Minimum of Exponential Random Variables</h4><p>If variables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*juPbB1GkAWc6w3VYRSemug.png" /></figure><p>follow exponential distributions with parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*Z37xpi9Z9rIDsGlsyqSpcA.png" /></figure><p>then:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*5B1SAOTO78GeF-zkepnKbw.png" /></figure><p>This property is very useful in <a href="https://en.wikipedia.org/wiki/Greedy_algorithm">Greedy Algorithms</a>, where the minimum of the given outputs is calculated.</p><h4>4. Uniform and Exponential Distribution</h4><blockquote>If X and Y are independent exponential random variables with the same rate λ&gt;0, then the ratio of <strong><em>X</em></strong> and <strong><em>X+Y</em></strong> follows a uniform distribution between 0 and 1.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*XXBXIRVGZ83qonvgiv4yfQ.png" /></figure><p>It is particularly useful in simulation and random sampling, as it reveals a deep connection between exponential and uniform distributions.</p><h4>5. Additive Property</h4><blockquote>The sum of <strong><em>n</em></strong> independent exponential random variables with the same rate λ&gt;0 follows a Gamma distribution.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*QUMbA8BqASaYp66GeTH2ig.png" /></figure><p>This property has wide applications in modeling cumulative event times and analyzing systems with multiple independent components.</p><h3>Summary</h3><p>The exponential distribution’s unique properties, such as memorylessness, its connection to the uniform distribution, and its moment-generating simplicity, make it a versatile tool.</p><p>Whether you’re calculating moments, simulating random processes, or exploring theoretical probabilities, these characteristics highlight the distribution’s practical utility.</p><p>Below, I’ve included a few links that explore the properties of the exponential distribution in greater depth.</p><p>Enjoy!</p><p>Exponential distribution by StatLect — <a href="https://www.statlect.com/probability-distributions/exponential-distribution">https://www.statlect.com/probability-distributions/exponential-distribution</a></p><p>Exponential distribution Properties — <a href="https://en.wikipedia.org/wiki/Exponential_distribution#Properties">https://en.wikipedia.org/wiki/Exponential_distribution#Properties</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=604e500949a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Shapley Values in R]]></title>
            <link>https://medium.com/r-evolution/understanding-shapley-values-in-r-2eaa99365b74?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/2eaa99365b74</guid>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Sun, 25 May 2025 06:56:56 GMT</pubDate>
            <atom:updated>2025-05-25T07:06:27.303Z</atom:updated>
            <content:encoded><![CDATA[<h4>Shapley Values can be a really useful tool in data analysis and machine learning. Here is an introduction and a step-by-step guide on how to use them in R.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bg0uW2rhnZ_9M3Yrh-Ihg.jpeg" /></figure><h3>Highlights</h3><ul><li>Shapley Values explain how much each feature contributes to a model’s prediction.</li><li>Based on cooperative game theory, they fairly distribute a prediction among all input features.</li><li>This post shows how to compute and interpret Shapley Values in R using the iml package.</li><li>Includes a step-by-step example with the Boston housing dataset and a Random Forest model.</li></ul><h3>Introduction</h3><p>In the world of machine learning and explainable AI (XAI), understanding model predictions is just as crucial as making accurate forecasts.</p><p>One powerful method for feature attribution is <strong>Shapley Values</strong>, which originates from cooperative game theory.</p><p>Shapley Values help us determine how much each feature contributes to a model’s prediction, making them widely used in finance, healthcare, and actuarial science.</p><p>In this post, I’ll explore how to compute and interpret Shapley Values in <strong>R</strong> using the iml package.</p><h3>What Are Shapley Values?</h3><p>Shapley Values, introduced by <a href="https://pl.wikipedia.org/wiki/Lloyd_Shapley">Lloyd Shapley</a> in 1953, provide a fair way to distribute an outcome among multiple contributors.</p><p>In machine learning, they allocate the prediction difference to each feature by averaging its impact across all possible feature combinations.</p><p>Shapley Values provide a <strong>theoretically sound</strong> way to interpret model decisions, making them particularly useful for:</p><ul><li><strong>Feature importance analysis</strong>: Understanding which features drive predictions.</li><li><strong>Fairness</strong>: Detecting bias in decision-making models.</li><li><strong>Regulatory compliance</strong>: Meeting explainability requirements in fields like finance and healthcare.</li></ul><p>Unlike simpler feature importance methods (e.g., <em>correlation</em> or <em>coefficients in linear models</em>), Shapley Values <strong>account for feature interactions</strong>, offering more reliable explanations.</p><h3>Implementing Shapley Values in R</h3><p>Let’s look at how to use and interpret Shapley Values in R, creating a simple machine learning model.</p><h4>Step 1: Install and Load Required Packages</h4><p>To compute Shapley Values, we use the iml package, which provides tools for model interpretation in R.</p><p>Install packages, if needed, and then load them:</p><pre>install.packages(&quot;iml&quot;)<br>install.packages(&quot;randomForest&quot;)<br>install.packages(&quot;MASS&quot;)<br><br>library(iml)<br>library(randomForest)<br>library(MASS)</pre><h4>Step 2: Train a Model</h4><p>We’ll use the <strong>Boston housing dataset</strong>, which predicts median house prices based on various features.</p><p>To look at what this dataset looks like, you can write ‘Boston’ in your R console and click ‘Run’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*JGslUT8bwVURZjahM5R-Eg.png" /></figure><p>Set the seed to ensure consistent results later. If not set, the model will be estimated differently, therefore, a recreation of your result won’t be possible.</p><p>Our model is a <strong>Random Forest</strong> model, with <strong>100 trees</strong> (<em>ntree</em> parameter).</p><pre>set.seed(42)<br>rf_model &lt;- randomForest(medv ~ .,data = Boston, ntree = 100)</pre><h4>Step 3: Compute Shapley Values</h4><p>Now, create an iml::Predictor object and calculate Shapley Values for a sample observation.</p><pre>predictor &lt;- Predictor$new(rf_model, data = Boston[, -14], y = Boston$medv)<br><br>observation &lt;- Boston[1, -14]<br><br>shapley &lt;- Shapley$new(predictor, x.interest = observation)<br><br>print(shapley)</pre><p>Results show the predicted value, which is the median house price in the Boston area, and the average prediction.</p><p>At the bottom, a table shows values of <em>phi</em>, which tell us how big an impact the predicted value has on a given feature.</p><p>The bigger the value, the bigger the impact on the final prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*Yu9pSkRaAqTN_KbS2h92LQ.png" /></figure><h4>Step 4: Visualize Shapley Values</h4><p>A plot helps interpret feature contributions values of <em>phi</em>.</p><pre>plot(shapley)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*QvIRqBYw5fO-FoegIp3tUA.png" /></figure><p>While performing a project, we can use a second method for feature importance analysis and then select the best features.</p><p>Based solely on Shapley Values, the <em>lstat</em> and <em>indus</em> variables have the biggest impact on the predicted median house price, while the <em>chas</em> and <em>zn</em> variables have the lowest impact.</p><h3>Conclusion</h3><p>Shapley Values provide an effective way to <strong>explain complex models</strong>, offering insights into feature importance while considering feature interactions.</p><p>Using the iml package in R, we can compute and visualize Shapley Values to better understand model decisions.</p><p>By integrating these methods into your workflow, you can build <strong>trustworthy, transparent, and fair</strong> machine-learning models.</p><p>Try experimenting with different datasets and models to see how feature contributions vary!</p><p>Additionally, if you want to learn more about Shapley Values, I include a couple of links at the bottom for reference.</p><p>Enjoy!</p><p>shapley package — RDocumentation -<a href="https://www.rdocumentation.org/packages/shapley/versions/0.1">https://www.rdocumentation.org/packages/shapley/versions/0.1</a></p><p>A gentle introduction to SHAP values in R<strong> </strong><a href="https://www.r-bloggers.com/2019/03/a-gentle-introduction-to-shap-values-in-r/"><strong>— </strong>https://www.r-bloggers.com/2019/03/a-gentle-introduction-to-shap-values-in-r/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2eaa99365b74" width="1" height="1" alt=""><hr><p><a href="https://medium.com/r-evolution/understanding-shapley-values-in-r-2eaa99365b74">Understanding Shapley Values in R</a> was originally published in <a href="https://medium.com/r-evolution">R-evolution</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner’s Guide to the Poisson Distribution]]></title>
            <link>https://medium.com/@eryk.faracik/beginners-guide-to-the-poisson-distribution-325c8a5aff50?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/325c8a5aff50</guid>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Fri, 23 May 2025 11:05:29 GMT</pubDate>
            <atom:updated>2025-05-23T11:08:39.920Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Poisson distribution is widely used to model insurance claims. It’s a discrete probability distribution with its mean equal to its variance.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6U4nb6YxOBNqgARzthQerA.jpeg" /></figure><p>Whether you’re analyzing insurance claims, call center traffic, or rare events in sports, understanding the Poisson distribution can simplify complex problems.</p><p>Here’s a brief overview of its key facts and practical insights.</p><h3>What is the Poisson Distribution?</h3><p>The Poisson distribution models the <strong>number of events</strong> that occur in a <strong>fixed interval</strong>, given that these events happen <strong>independently</strong> and at a constant average rate.</p><p>It’s a discrete probability distribution, and the function that describes its distribution is called the <strong>probability mass function (PMF)</strong>.</p><p>PMF for the Poisson distribution is given by the formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*yxnruvjanMJjrkjtHWjCDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*OFEmTQA5A5SgdjIPYaFoqQ.png" /><figcaption><strong>Formula 1.</strong> PMF for the Poisson distribution.</figcaption></figure><h3>Key Characteristics</h3><h4>Discrete Distribution</h4><p>The Poisson distribution takes as arguments only integer values (0, 1, 2,…).</p><p>The plot of the Poisson distribution is presented as dots linked with a line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*KwuzHH1JC7C9ike4KFDatw.png" /><figcaption><strong>Image 1</strong>. Plot of the Poisson distribution for different values of the parameter λ.</figcaption></figure><h4>Mean = Variance</h4><p>The expected value of the Poisson distribution it’s also its variance.</p><ul><li><strong>Since the variance equals the mean, a higher expected value implies greater variability. </strong>For instance, if λ=2, outcomes will typically cluster closely around 2. However, if λ=100, outcomes will vary significantly, reflecting the broader spread.</li><li><strong>Unlike distributions with constant variance, the Poisson distribution’s variability grows as the mean increases.</strong> This is crucial when modeling rare events that become more frequent over time (e.g., insurance claims in a growing customer base).</li><li>The Poisson distribution is inherently skewed, especially for small λ values. <strong>As λ increases, the distribution shape becomes more symmetric and resembles a normal distribution</strong> — a property known as the <strong>Poisson limit theorem</strong>.</li><li>Since the Poisson variance scales with the mean, it’s particularly useful as an approximation for binomial distributions in cases with a large number of trials and low probability of success.</li></ul><h4>Events are Independent</h4><p>This means that one event occurring doesn’t affect the likelihood of another.</p><p>Also, the sum of two or more Poisson random variables follows the Poisson distribution, with the expected number of occurrences equal to the sum of the expected number of occurrences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*meevh7nWlxZ1-gVpDCndHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*oRKDFkpt1Bjxio2JnCwFXw.png" /><figcaption><strong>Formula 2.</strong> The sum of the Poisson random variables follows the Poisson distribution.</figcaption></figure><h3>Example</h3><p><em>Imagine an insurance company observes an average of 3 car accidents per day in a certain city. What’s the probability of exactly 5 accidents occurring tomorrow?</em></p><p>The expected number of car accidents in one day is 3.</p><p>Therefore, we can say that the number of car accidents in one day follows a Poisson distribution with parameter λ=3.</p><p>Let’s denote this variable as X.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*3QtD8Qt-D_qa708vaFRb_A.png" /></figure><p>The probability of exactly 5 accidents can be written as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/172/1*FaHvgl6vbpqjSsBdDWXhkg.png" /></figure><p>Therefore, the desired probability is equal to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*yeQCyeGtOw6v-jVXo9AISQ.png" /></figure><p>So, there’s about a <strong>10% chance</strong> of exactly 5 accidents.</p><h3>Summary</h3><p>The Poisson distribution is a simple yet powerful model for random, independent events. Its versatility makes it a cornerstone in actuarial science, statistics, and beyond.</p><p>Whether estimating claim numbers or forecasting another number of events, mastering this distribution can greatly enhance your analytical toolkit.</p><p>After this quick guide, you should have a basic understanding of what the Poisson distribution is. However, if you’d like to know more, which I encourage you to do, I’ve included a couple of links for reference.</p><p>Have fun!</p><p>Poisson distribution by <a href="https://www.statlect.com/about/#author">Marco Taboga</a>, PhD-<strong> </strong><a href="https://www.statlect.com/probability-distributions/Poisson-distribution">https://www.statlect.com/probability-distributions/Poisson-distribution</a></p><p>The Poisson Distribution by Newcastle University<strong> — </strong><a href="https://www.ncl.ac.uk/webtemplate/ask-assets/external/maths-resources/images/Poisson_dist.pdf">https://www.ncl.ac.uk/webtemplate/ask-assets/external/maths-resources/images/Poisson_dist.pdf</a></p><p>Poisson Distribution | Definition, Formula, Table, and Examples <strong>— </strong><a href="https://www.geeksforgeeks.org/poisson-distribution/">https://www.geeksforgeeks.org/poisson-distribution/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=325c8a5aff50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Quick Guide to ggrigdes Plots in R]]></title>
            <link>https://medium.com/r-evolution/a-quick-guide-to-ggrigdes-plots-in-r-7a1b7830434a?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a1b7830434a</guid>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Mon, 19 May 2025 10:05:01 GMT</pubDate>
            <atom:updated>2025-05-19T10:05:01.581Z</atom:updated>
            <content:encoded><![CDATA[<h4>Recently, in my job as a Data Analyst, my project manager introduced me to ggridges plots in R. I think they look cool and are also pretty useful. Therefore, here is a quick guide on how to create ggridges plots in R.</h4><p>The name <strong>ggridges</strong> comes from the band <strong>Joy Division</strong>. The package is inspired by the iconic cover art of their album <em>Unknown Pleasures</em>, which features a series of stacked ridgelines representing radio waves. This visual style has been adapted in the ggridges package for R to create “ridge plots“ which display overlapping density plots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*ax1yt4gQZcbUnryEz6e5lA.png" /><figcaption>Image 1. Cover art for the Joy Division “Unknown Pleasures” album — inspiration for the ridges plots.</figcaption></figure><h3>Why Use ggridges Plots?</h3><p>Here are three key reasons to use <strong>ggridges</strong> plots:</p><ol><li><strong>Visualizing Multiple Distributions</strong><br>Ridge plots are ideal for comparing distributions of a variable across different categories or groups. Their overlapping density curves make patterns and differences between groups easy to identify at a glance.</li><li><strong>Space-Efficient Design</strong><br>Unlike separate histograms or box plots for each category, ggridges plots save space by stacking distributions vertically, making them perfect for datasets with many groups.</li><li><strong>Aesthetic Appeal</strong><br>Inspired by Joy Division’s <em>Unknown Pleasures</em> album cover, ggridges plots are visually striking and modern. They can make your visualizations stand out in reports and presentations while still being highly informative.</li></ol><p>After a brief introduction and 3 key reasons to use <strong>ggridges</strong> plots, let’s move on to the R code and learn, step by step, how to plot data using these types of plots.</p><h3>Step 1. Install and Load the Required Packages</h3><p>First, ensure you have the necessary packages installed. You’ll need ggridges and ggplot2.</p><pre>#If not already installed<br><br>install.packages(&quot;ggridges&quot;)<br>install.packages(&quot;ggplot2&quot;)<br><br>#Load the packages<br><br>library(ggridges)<br>library(ggplot2)</pre><h3>Step 2. Prepare Example Data</h3><p>We’ll use the iris dataset for demonstration, which is built into R.</p><pre>#Assign the data variable to iris dataset<br>data -&gt; iris<br><br>#View the structure of the dataset<br>str(data)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Izs8Y3waevmbP0K-dtlmuw.png" /></figure><h3>Step 3. Create a Basic ggridges Plot</h3><p>We’ll plot the distribution of the Sepal.Length variable for each Species.</p><pre>ggplot(data, aes(x = Sepal.Length, y = Species, fill = Species)) +<br>  geom_density_ridges() +<br>  theme_minimal() +<br>  labs(<br>    title = &quot;Distribution of Sepal Length by Species&quot;,<br>    x = &quot;Sepal Length&quot;,<br>    y = &quot;Species&quot;<br>  )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YfQxfWKboBilJpLnB-ekbA.png" /></figure><h3>Step 4. Customize the Plot</h3><p>You can further customize the appearance of your plot with additional options:</p><ul><li><strong>Adjust Transparency</strong>: Use the alpha argument to control transparency.</li><li><strong>Change Fill Colors</strong>: Modify the fill aesthetic to use a custom palette.</li><li><strong>Add Scaling</strong>: Adjust the scale parameter in geom_density_ridges() to control the overlap of the ridgelines.</li></ul><p>Here’s an enhanced example:</p><pre>ggplot(data, aes(x = Sepal.Length, y = Species, fill = Species)) +<br>  geom_density_ridges(alpha = 0.7, scale = 1.5) +<br>  scale_fill_manual(values = c(&quot;skyblue&quot;, &quot;orange&quot;, &quot;lightgreen&quot;)) +<br>  theme_minimal() +<br>  theme(legend.position = &quot;none&quot;) +<br>  labs(<br>    title = &quot;Enhanced Ridge Plot of Sepal Length by Species&quot;,<br>    x = &quot;Sepal Length&quot;,<br>    y = &quot;Species&quot;<br>  )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bAebalCycaVPr0x3pPKDpA.png" /></figure><h3>Conclusion</h3><p><strong>ggridges</strong> plots are a powerful and visually appealing way to compare distributions across multiple groups.</p><p>They</p><ul><li>save space,</li><li>enhance readability,</li><li>and add a modern aesthetic to your data visualizations.</li></ul><p>Whether you’re exploring data or creating polished presentations, <strong>ggridges</strong> plots can elevate your analytical storytelling in R.</p><p>Do you find these types of plots interesting?</p><p>If so, I’ve included two links where you can explore more about <strong>ggridges</strong> plots and find additional information.</p><p>Introduction to ggridges by cran.r-project — <a href="https://cran.r-project.org/web/packages/ggridges/vignettes/introduction.html">https://cran.r-project.org/web/packages/ggridges/vignettes/introduction.html</a></p><p>ggridges: Ridgeline plots in ggplot2 by wilkelab.org — <a href="https://wilkelab.org/ggridges/">https://wilkelab.org/ggridges/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a1b7830434a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/r-evolution/a-quick-guide-to-ggrigdes-plots-in-r-7a1b7830434a">A Quick Guide to ggrigdes Plots in R</a> was originally published in <a href="https://medium.com/r-evolution">R-evolution</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn the Basics of the Effective Rate of Interest Today]]></title>
            <link>https://medium.com/@eryk.faracik/learn-the-basics-of-the-effective-rate-of-interest-today-5a29b009e1b7?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a29b009e1b7</guid>
            <category><![CDATA[financial-mathematics]]></category>
            <category><![CDATA[actuarial-science]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 09:26:43 GMT</pubDate>
            <atom:updated>2025-01-17T10:13:01.066Z</atom:updated>
            <content:encoded><![CDATA[<h4>Your Comprehensive Guide to Understanding the Effective Rate of Interest — Simplified for Beginners and Ready to Apply Today!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Y93LEC3g7Dx91uLO7EffQ.jpeg" /></figure><p>If you deposit $1,000 into a savings account on December 31, 2024, and have $1,040 a year later, the $1,040 is the accumulated value. Your money earned $40 in interest, which, divided by the initial $1,000 deposit, gives a 4% annual effective rate of interest.</p><p>Alright, you’re all set — just kidding! There’s much more to explore!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rkKcUzcK8jB2E_oHv2r1rw.png" /><figcaption><strong>Image 1.</strong> A $1,000 investment made at the end of 2024 earned $40 in interest during 2025. The annual effective rate of interest for this period is 4%. For simplicity, it is labeled as <strong>annual effective</strong> on the graph.</figcaption></figure><h3>What is the Effective Rate of Interest?</h3><p>Simply put, the effective rate of interest (also known as the effective interest rate) is the real interest earned on an investment over a specific period.</p><p>When we refer to the <strong>annual effective rate of interest</strong>, we are specifically looking at the interest earned during one year of investment.</p><h4>Definition</h4><p>First of all, in this post, when I say real return, I am referring to the return based on the effective rate of interest, without accounting for the inflation rate.</p><p>The real interest rate, which adjusts the effective interest rate for inflation, will not be discussed in this post.</p><p>One possible definition of the effective interest rate is as follows:</p><p><strong><em>An effective interest rate is a real return on a savings account or any interest-paying investment when compounding effects are considered.</em></strong></p><p>You may have questions about compounding effects. In the initial example, I mentioned that interest is earned at the end of the year (one compounding period).</p><p>However, interest can also be compounded more frequently — semi-annually, quarterly, or monthly — resulting in multiple compounding periods within the year.</p><p>Banks often advertise a nominal interest rate, which assumes no compounding, while the effective rate reflects how often interest is earned and reinvested.</p><p>For instance, with monthly compounding, the effective rate accounts for interest being reinvested twelve times a year.</p><p>Now, let’s explore how to express the effective interest rate as a formula.</p><h4>Formulas</h4><p>To calculate the annual effective interest rate based on the annual nominal interest rate, we can use the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*4SFxA1FmRtRIRkUHOzb3KQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*JjfDhpZruVf8QD4CrhBtCA.png" /><figcaption><strong>Formula 1.</strong> Deriving the Annual Effective Interest Rate from the Annual Nominal Interest Rate</figcaption></figure><p>Sometimes, a more useful approach is to calculate the effective interest rate for a period shorter than one year, especially when we have an annual nominal interest rate compounded <strong>m</strong> times per year.</p><p>In this case, the effective interest rate for one compounding period is equal to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*tCq186R9mTnOTb56FwqjJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*GgyvQSUOQ4sGSxusov26Xg.png" /><figcaption><strong>Formula 2.</strong> Effective Interest Rate for One Compounding Period, which Occurs <strong>m</strong> Times During One Year.</figcaption></figure><p>Looking at the first example given at the beginning, we can compute the effective interest rate based on the initial amount of money invested and the amount earned at the end of the investment.</p><p>The formula for the effective interest rate during this period can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*DXvpI2Wqw6luc5oT4OLU5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*6XJ9zu8EFLgRj5rk8Hv9Hg.png" /><figcaption><strong>Formula 3.</strong> Annual Effective Interest Rate in Year <strong>t</strong>.</figcaption></figure><p>Each of the presented formulas is useful and helps to fully understand what the effective interest rate represents.</p><p>If we look at the interest earned during a single month, it would be referred to as the <strong>monthly effective interest rate</strong>.</p><p>Similarly, if we consider the return on investment over two years, we would calculate the <strong>2-year effective interest rate</strong>.</p><h3>Usage</h3><p>In actuarial science, the effective rate of interest is commonly used to calculate the present and accumulated (future) values of cash flows.</p><p>A <strong>cash flow</strong> refers to any money spent or earned, such as a salary or dividends, with some being negative (money spent).</p><p>The <strong>accumulated value</strong> is the amount after interest is applied over time, while the present value represents the worth of future cash flows today.</p><p>Calculating the accumulated value is called <strong>accumulating</strong>, and calculating the present value is called <strong>discounting</strong>.</p><h4>Accumulated Value</h4><p>Let’s start with the general formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*pW86RpJe_xKzmkxlC4Fpkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*WuABypME-W1PKDvBHL1w2w.png" /><figcaption><strong>Formula 4.</strong> Accumulated value at year <em>t+k</em> for a deposit made in year <em>t</em>.</figcaption></figure><p>To calculate the accumulated (or future) value of money deposited at a given time <em>t</em>, we multiply it by <em>(1+effective interest rate)</em> raised to the power of the number of compounding periods.</p><p>Between years <em>t</em> and <em>t+k</em>, there are <em>k</em> years. If there are <em>m</em> compounding periods per year, the total number of compounding periods is <em>m times k</em>.</p><p>Most of the time, <em>t</em> represents the present moment, so it is equal to 0.</p><p>However, the general formula can be used to calculate the accumulated value of a cash flow at any given point in time.</p><h4>Present Value</h4><p>The formula for present value is the inverse of the accumulated value formula; instead of multiplying the deposit by <em>(1+j-effective interest rate)</em>, we divide it (discount it).</p><p>It can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*wPqeM6SPCFMo9oiuxkTQvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*q9D9hiDe8EtbVmXBy9ucrA.png" /><figcaption><strong>Formula 5.</strong> Present value at year <em>t</em> of a cash flow occurring in year <em>t+k</em>.</figcaption></figure><p>Similarly to the accumulated value, year <em>t</em> is often equal to the current moment, or year 0.</p><p>Let’s look into these formulas in action with the two examples below.</p><h3>Examples</h3><h4>Example 1.</h4><p><em>Mary deposited $100 into her savings account today. She plans to wait 7 years before withdrawing her money. The annual effective interest rate for this savings account is 7.5%, compounded at the end of each year. Calculate the amount of money Mary will have after 7 years.</em></p><p>The first step, which is helpful in financial mathematics problems, is to organize all the information provided in the problem into a graph — more specifically, a <strong>timeline</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5leyo1w6pTkWzzC9k2k-Q.png" /><figcaption><strong>Image 2.</strong> $100 is deposited at time 0 (today) with an annual effective interest rate of 7.5%, and accumulated values at time 1 and time 7 (the end of the first and seventh years, respectively).</figcaption></figure><p>Mary deposited $100 at time 0 (today), and her money earns an annual effective interest rate of 7.5%.</p><p>The compounding period here is one year.</p><p>We are tasked with calculating the amount of money Mary will have after 7 years, which is the accumulated value of her money at <em>t=7</em>.</p><p>We know the initial deposit amount, the number of compounding periods (7), and the annual effective interest rate. Let’s substitute these values into <strong>Formula 4</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*WrRsCljqmWy-iNVaR4iKXQ.png" /></figure><p>So, the answer is that the amount Mary will have in her savings account after 7 years is <strong>$165.90</strong>.</p><h4>Example 2.</h4><p><em>John deposited money into his savings account three years ago. His current balance is $3,000. The annual nominal interest rate, compounded monthly, was 12% throughout the 3-year period. What was the amount John initially deposited?</em></p><p>Similarly to the previous example, let’s place the values on a timeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uG7XFdtBqCkFuE0Lp6ok-g.png" /><figcaption>I<strong>mage 3.</strong> $3,000 is accumulated at the end of 3 years (36 months) from an unknown amount <em>X</em> deposited at time 0. Calculate the accumulated value at the end of one year (12 months) given an annual nominal interest rate compounded monthly, equal to 12%.</figcaption></figure><p>$3,000 is the accumulated value of John’s initial deposit after three years. However, the compounding period is not one year.</p><p>This can be determined by the definition of the annual nominal interest rate.</p><p>It is stated that the interest is compounded monthly, so the compounding period is one month.</p><p>The total number of compounding periods is equal to the number of months in a year (12) times the number of years (3), which gives 36 periods.</p><p>To calculate the <em>j effective</em> interest rate for one month, let’s divide the annual nominal interest rate by the number of compounding periods in one year, which is the number of months:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*blxtXsJrhQtLuCvrY-_G-Q.png" /></figure><p>Having calculated the monthly effective interest rate and gathered all the other necessary information, we can plug it directly into the present value <strong>Formula 5</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*E5nij-zT_jYobcNLfJOGmA.png" /></figure><p>So, the answer is that John initially deposited <strong>$2,096.77</strong> into his savings account.</p><h3>Summary</h3><p>The effective rate of interest helps calculate the present and accumulated values of cash flows.</p><p>The present value is the current worth of future cash flows, while the accumulated value shows how money grows with interest over time.</p><p>The formulas for these values are inverses, so one can be calculated from the other. Earning interest is called accumulating, while the reverse is discounting.</p><p>If you found this helpful and want to learn more, check out the links below!</p><p>More Actuarial Concepts Explained on My Blog — <a href="https://www.erykfaracik.com/">https://www.erykfaracik.com/</a></p><p>Present Value vs Future Value by Project Management Academy — <a href="https://projectmanagementacademy.net/resources/blog/present-value-vs-future-value/">https://projectmanagementacademy.net/resources/blog/present-value-vs-future-value/</a></p><p>Present Value Calculator — <a href="https://www.calculator.net/present-value-calculator.html?c1futurevalue=100&amp;c1yearsv=10&amp;c1interestratev=6&amp;x=Calculate#future-money">https://www.calculator.net/present-value-calculator.html?c1futurevalue=100&amp;c1yearsv=10&amp;c1interestratev=6&amp;x=Calculate#future-money</a></p><p>Future Value Calculator — <a href="https://www.calculator.net/future-value-calculator.html?cyearsv=10&amp;cstartingprinciplev=100&amp;cinterestratev=6&amp;ccontributeamountv=0&amp;ciadditionat1=end&amp;printit=0&amp;x=Calculate#calresult">https://www.calculator.net/future-value-calculator.html?cyearsv=10&amp;cstartingprinciplev=100&amp;cinterestratev=6&amp;ccontributeamountv=0&amp;ciadditionat1=end&amp;printit=0&amp;x=Calculate#calresult</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a29b009e1b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rayleigh Distribution: Definition, Formulas, and More]]></title>
            <link>https://medium.com/@eryk.faracik/rayleigh-distribution-definition-formulas-and-more-73f774f330bb?source=rss-c22f9c750ea2------2</link>
            <guid isPermaLink="false">https://medium.com/p/73f774f330bb</guid>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[probability-distributions]]></category>
            <category><![CDATA[actuarial-science]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Eryk Faracik]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 11:37:18 GMT</pubDate>
            <atom:updated>2025-01-17T10:13:34.545Z</atom:updated>
            <content:encoded><![CDATA[<h4>Common distributions like Normal, t-Student, and Uniform are widely used for their versatility and simplicity, but lesser-known ones, like the Rayleigh distribution, also have valuable applications worth exploring.</h4><p>The Rayleigh distribution, a one-parameter continuous distribution and a special case of the <strong>Weibull</strong> distribution (k=2), is named after Lord Rayleigh.</p><p>It often models the magnitude of a vector in a plane, such as two-dimensional wind speed with uncorrelated, normally distributed components of equal variance and zero mean.</p><p>This post explores its PDF, CDF, mean, variance, and moments, concluding with R code for generating and plotting Rayleigh-distributed numbers.</p><h3>Definition</h3><p>The Rayleigh distribution, a single-parameter continuous probability distribution, is defined by its PDF and CDF, which describe the probability and cumulative probability of a random variable, respectively.</p><p>The <strong>PDF</strong> is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*Alyqyld-jrdnsVZQL6qFrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*-RaOZo09omTk4oaqEqtgKw.png" /></figure><p>For a better understanding of the formula, below is a graph of several different Rayleigh distribution density functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*CG4xTmqlIHr4cSmAz5v25w.png" /></figure><p>The Rayleigh distribution’s <strong>CDF</strong> has the formula equal to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*YQBHr0XkPp92e421zaiSkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*-RaOZo09omTk4oaqEqtgKw.png" /></figure><p>Similarly to the PDF, below is a plot of different Rayleigh distribution CDFs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*p6c9Uam_yTw_8x6YVll1nQ.png" /></figure><p>The Rayleigh distribution applies only to nonnegative values, making it useful for modeling insurance losses, similar to <strong>log-normal</strong> and <strong>Pareto</strong> distributions.</p><p>Next, let’s explore its mean, variance, and moments.</p><h3>Formulas</h3><p>Knowing formulas for expected value, variance, and moments is invaluable for quiz games and actuarial exams.</p><p>For instance, you can skip lengthy integrations with the exponential distribution’s variance formula and parameter <strong>λ</strong>. The same applies to the Rayleigh distribution.</p><p>I’ll share its expected value, variance, and a general raw moments formula — essential tools for actuarial exam prep!</p><h4>Mean and Variance</h4><p>The mean (expected value) of the Rayleigh distribution is given by the formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*U2-s6bpJRl9nxe240Jozlg.png" /></figure><p>and the variance, which is the difference between the second raw moment and the square of the first moment, is given by the formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*8bhmaAkEGyQCp-jaHrz5pQ.png" /></figure><p>These formulas might seem unusual due to the presence of π, and I felt the same initially. However, discovering a general formula for the raw moments clarified everything. Let’s explore it!</p><h4>Moments</h4><p>In the Rayleigh distribution, the <em>k-th</em> raw moment is given by the formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*_szeGmrYuLylM98XqqbHKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*XgT2IuSV4i6q7OrE-sjYMw.png" /></figure><p>To check if the formula for the first-order raw moment, which is the expected value, matches this general formula, let’s set <em>k=1</em> and calculate the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDds4yqh_4GNf3A8EQfDhA.png" /></figure><p>The value is the same as the one from the expected value formula presented earlier.</p><h3>Rayleigh Distribution in R</h3><p>Finally, here’s sample R code to visualize the Rayleigh distribution. Using the <strong>bayesmeta</strong> package, you can specify different σ values or input them directly into the function.</p><p>Copy the code and experiment to better understand the distribution and enhance your R skills.</p><p>A link to the R documentation is included for more details.</p><pre>#Install packages<br>install.packages(&quot;bayesmeta&quot;)<br>library(bayesmeta)<br><br>#Define scale parameters<br>sigma_1 &lt;- 2<br>sigma_2 &lt;- 4<br>sigma_3 &lt;- 6<br><br>#Plot densities<br>x &lt;- seq(0,10,le=200)<br>plot(x, drayleigh(x, scale=sigma_1), type=&quot;l&quot;, col=&quot;darkgreen&quot;,<br> xlab=expression(x), ylab=expression(&quot;probability density &quot; *f(x)))<br>lines(x, drayleigh(x, scale=sigma_2), col=&quot;red&quot;)<br>lines(x, drayleigh(x, scale=sigma_3), col=&quot;blue&quot;)<br>abline(h=0, v=0, col=&quot;grey&quot;)<br><br>#Add legend to the plot<br>legend(&quot;topright&quot;, <br> legend = c(2,4,6), <br> col = c(&quot;darkgreen&quot;, &quot;red&quot;, &quot;blue&quot;), <br> lty = 1, <br> title = &quot;Scale Parameters&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Siej6Tl5Tfosqlqt8Cdo-Q.png" /></figure><h3>Summary</h3><p>The Rayleigh distribution, a single-parameter continuous distribution, and a special case of the Weibull distribution are useful for modeling nonnegative data, such as vector magnitudes or insurance losses.</p><p>Its raw moments’ formula simplifies complex calculations, making it valuable for recognizing data patterns and tackling actuarial problems.</p><p>I hope you found this post insightful! Have you encountered the Rayleigh distribution or other interesting lesser-known distributions? Share your thoughts in the comments or message me — I’d love to hear from you!</p><p>Lastly, explore the links below for more on the Rayleigh distribution and its R applications and a more detailed version of this article on my blog.</p><p>Rayleigh Distribution: Definition, Formulas, and More by erykfaracik.com — <a href="https://www.erykfaracik.com/blog/rayleigh-distribution-definition-formulas-and-more">https://www.erykfaracik.com/blog/rayleigh-distribution-definition-formulas-and-more</a></p><p>Rayleigh Distribution by ScienceDirect — <a href="https://www.sciencedirect.com/topics/engineering/rayleigh-distribution">https://www.sciencedirect.com/topics/engineering/rayleigh-distribution</a></p><p>Rayleigh Distribution: Definition, Uses, Mean, Variance by Statistics How To — <a href="https://www.statisticshowto.com/rayleigh-distribution/">https://www.statisticshowto.com/rayleigh-distribution/</a></p><p>R Documentation: The Rayleigh distribution — <a href="https://search.r-project.org/CRAN/refmans/bayesmeta/html/drayleigh.html">https://search.r-project.org/CRAN/refmans/bayesmeta/html/drayleigh.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73f774f330bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>