<?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 Ben Lahner on Medium]]></title>
        <description><![CDATA[Stories by Ben Lahner on Medium]]></description>
        <link>https://medium.com/@benlahner?source=rss-ce5743796d92------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8IFUWQ4hoDhQcojE6t5Dag.jpeg</url>
            <title>Stories by Ben Lahner on Medium</title>
            <link>https://medium.com/@benlahner?source=rss-ce5743796d92------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:51:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@benlahner/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[Tutorial: Finetune a LLM to, like, talk like a Valley Girl]]></title>
            <link>https://medium.com/@benlahner/how-to-practice-talking-to-a-valley-girl-1d8ecb687b74?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d8ecb687b74</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Thu, 23 Jul 2026 05:41:54 GMT</pubDate>
            <atom:updated>2026-07-23T20:02:18.091Z</atom:updated>
            <content:encoded><![CDATA[<p>Valley Girls — (in)famous for their drama-loving personalities and sentences punctuated by excessive uses of “Oh my GOD”, “like”, “literally”, and “okay whaaaat??”’s — can challenge the patience of even the Dalai Lama. But they are our friends, our nieces, our coworkers, our neighbors, and our daughters — we cannot go through life without them.</p><p>But that doesn’t mean some extra conversational practice wouldn’t hurt anyone. After all, tools abound for practicing job interviews, wedding speeches, and cross-cultural scenarios, so why not a tool to practice talking to a Valley Girl?</p><p>That is why I made an <a href="https://huggingface.co/spaces/benlahner/valleygirl">AI chatbot</a> that talks exactly like a Valley Girl so you can practice in the comfort of your own home.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BT406LB5N2ThRTgzc2j8nA.png" /></figure><p>Expertly navigate its generational lingo and unwanted digs into your personal life. Take three deep breaths, and respond. And repeat.</p><ul><li>Play with the model on Huggingface <a href="https://huggingface.co/spaces/benlahner/valleygirl">here</a></li><li>See all code in my <a href="https://github.com/blahner/SFT-sandbox">GitHub repository</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d8ecb687b74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why your friends are more popular than you]]></title>
            <link>https://medium.com/@benlahner/why-your-friends-are-more-popular-than-you-e0ba24d0c321?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0ba24d0c321</guid>
            <category><![CDATA[friendship]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[puzzle]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[paradox]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Wed, 21 May 2025 21:33:33 GMT</pubDate>
            <atom:updated>2025-05-22T04:14:01.598Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9tZIt_jqShjMbEtPHI17dA.png" /></figure><p>Do you think you have more friends than your friends? Well, you probably don’t. And you also probably have fewer sexual partners than your partners, fewer publications than your co-authors, and fewer followers than your Instagram followers. Depressed yet?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*LES2idQKEej2xwcG0EjjMg.png" /><figcaption>Figure 1: Toy social network showing the “friendship paradox.” Each vertex v (i.e., a person) is labeled with numbers A/B, where A represents that vertex v’s number of friends (or edges), and B represents the average number of friends over all of vertex v’s friends. Green outlined vertices are examples where the vertex has fewer friends than the average of their friends. Over half (9/12) of the vertices show this paradoxical effect.</figcaption></figure><h3>Intuition</h3><p>This phenomena is known as the <strong>friendship paradox </strong>— on average, your friends have more friends than you. But this statement is also true for each of your friends… hence the paradox.</p><p>The intuition behind this paradox is essentially that it is rare to be friends with non-social people because, by definition, they do not interact with many people. So, your friends are likely to be social and thus have many friends. A relatively small number of people end up having many friends and thus skew the averages of the greater number of less social individuals. Thus, for much more than half of people in a social network, the statement “my friends have more friends than me” is true.</p><p>The friendship paradox is illustrated graphically in Figure 1 using an undirected graph where vertices represent people and edges represent friendship. Pretend you are the green filled node in the top left of Figure 1 with 3 friends (edges). Now look at your 3 friends and notice they have 2, 3, and 7 friends, respectively. So you have 3 friends and your friends have, on overage, 4 friends, making you feel less popular than your friends. But two of your friends also feel this way! And over the whole graph, 9/12 or 75% of the people feel this way too.</p><p>You might think that the friendship paradox holds for only a small subset of possible networks, but actually, it holds for any naturally forming network. The only case the friendship paradox does not hold is when each vertex (i.e., person) has the same number of edges (i.e., friends) as everyone else. And that case is so rare in social networks, especially large ones, that I am comfortable saying it never occurs. The math behind the friendship paradox describes this result beautifully.</p><h3>Mathematical derivation</h3><p>Now that we built an intuition around the friendship paradox, let’s examine it mathematically. Let’s focus on the <em>expected value</em> of the number of friends (edges) for any random person (vertex), denoted by E(e):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*89uL1KJkwHFImk6XtR5quA.png" /></figure><p>where d(v) is the degree of vertex v and |E| is the number of edges in the graph. Here, the expected value is the probability of a value multiplied by the value. The first term (d(v)/2|E|) is the probability of choosing a vertex v. In words, this describes the probability of choosing one of vertex v’s edges, then divide by 2 to choose vertex v (not vertex v’s friend). The second term is the degree of vertex v, given simply by d(v). We simplify this equation below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*ADsgzgOpXZiZMAdulgklww.png" /></figure><p>Now we take a detour to look at the variance (σ²) of the degrees of the vertices in a graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*aINERW6aQGW6HGLu8GLcFw.png" /></figure><p>We can also write the average number of edges (μ)<strong> </strong>of a random vertex as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*U-FONNk_x1LYKXjpjaG5oA.png" /></figure><p>where |V| is the number of vertices in the graph. Using this information, the next few equations simplify the variance equation. First, we expand equation 3:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*jFgZKP9BYYrSQWO4MMSmUg.png" /></figure><p>Next, we distribute the summation through the terms and simplify with equation 4 to get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*mSu8RX10xznjc8uc8xBWkA.png" /></figure><p>Now combine like terms and distribute the 1/|V| term:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*EiT4txHwnyAfvtfkRm35Jg.png" /></figure><p>Rearranging, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*R_eU8bYXbVbG9f676r1J5A.png" /></figure><p>Now we substitute the equation back into our expected value equation (equation #2) to get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*57frVZK3FgGwQSPa3OHOzg.png" /></figure><p>And finally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*4U4GnOEyuPE-RkxwrDaOwQ.png" /></figure><p>Ok great, but what does this mean? Above I said that the friendship paradox doesn’t arise in every graph structure, but it does arise in the graph structures that social networks tend to produce. Now we can see why. In order for our expected value of the number of friends for any random person (our E(e)) to be the same for everyone (i.e., the friendship paradox is <strong>not</strong> true), the variance of each vertex’s degrees (σ²) needs to be 0. In other words, everyone needs to have the same number of friends. This just doesn’t happen in the real world because some people are naturally more social than others.</p><p>In fact, social networks tend to have high variance in the degrees of each vertex because people vary greatly in how social they are — some are very outgoing with lots of friends while others are reserved with fewer friends. Thus, σ² will be much greater than 0 and the final term σ²/μ will be positive, meaning that our expected value of the number of friends for any random person will be greater than the average number of friends of a random person (μ).</p><h3>Conclusion</h3><p>Next time you’re feeling insecure about your friends being more popular than you, well, they probably are more popular than you. But on the bright side, you’re probably more popular than them too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0ba24d0c321" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TreeCV: The Skills-First Interactive Resume for the Modern Job Search]]></title>
            <link>https://medium.com/@benlahner/treecv-the-skills-first-interactive-resume-for-the-modern-job-search-d6e02e216e71?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6e02e216e71</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[resume]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Sat, 07 Dec 2024 15:30:40 GMT</pubDate>
            <atom:updated>2024-12-07T15:30:40.602Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s time to toss the traditional resume format in the ‘reject’ pile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kCLgpBoCGLkYzfZnrQQ-w.gif" /><figcaption>Toy example of TreeCV. See the <a href="https://github.com/blahner/TreeCV">GitHub repository</a> for more info.</figcaption></figure><p>Whether we like it or not, we live in a world where one stranger’s <a href="https://www.reddit.com/r/recruiting/comments/y9tkok/is_it_true_that_recruiters_only_spend_about_7/">7 second glance</a> at your resume separates you from your dream job. Hiring managers want to see a candidates skills and evidence of those skills, plain and simple. But a typical resume lists company names, projects, publications, awards, volunteer work etc., leaving it up to the hiring manager to search for the corresponding skills.</p><p>Your accolades are without a doubt important in the hiring decision, but they are secondary. Just hop on LinkedIn and look at any job posting — companies hire candidates that “are proficient in Python”, for example, not candidates that “have won two hackathons”. In a game where every second counts, you want to clearly communicate your skills first.</p><p><a href="https://github.com/blahner/TreeCV">TreeCV</a> addresses this fundamental mismatch by concisely showcasing your skills and evidence for those skills in an interactive, javascript-based tree. TreeCV works in the browser and defines each of your skills and accomplishments as color-coded nodes. Clicking on a node will expand or collapse that node’s children nodes making even the most accomplished resumes digestable and organized. Following the example above, a hiring manager will first see that you have a skill in “Python”, then, if that skill is of particular interest to the job, can expand the “Python” node to see evidence of that skill in the form of “won two hackathons” complete with links to your Python code on GitHub.</p><p>And applicants, no more cramming your resume or CV with posting-specific buzzwords. With TreeCV, a hiring manager can see all your skills in an instant. If they don’t care about a particular skill you have, they do not need to interact with it! No harm, no foul. But maybe they see a skill of yours that really separates you from the crowd that otherwise would not be obvious on a traditional resume.</p><h3>Try It Yourself</h3><p>See this <a href="https://github.com/blahner/TreeCV">GitHub repository</a> for more information on TreeCV and a Shrek-themed example you can fork, customize, and improve upon. TreeCV repurposes this great <a href="https://observablehq.com/@d3/collapsible-tree">collapsible tree</a> javascript code from D3 and adds the best elements of a static resume/CV as collapsible javascript boxes. You can visit my <a href="https://blahner.github.io/treecv/treecv.html">webpage</a> to explore a real example.</p><p>Hiring managers, would TreeCV make it easier for you to screen applicants? Applicants, would you feel you had a fairer shot at your dream job if you used TreeCV?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6e02e216e71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Make a Ticket Bot]]></title>
            <link>https://medium.com/@benlahner/how-to-build-your-own-ticket-bot-63c3d0706e92?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/63c3d0706e92</guid>
            <category><![CDATA[hiking]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[fun]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Sat, 20 Jul 2024 22:44:17 GMT</pubDate>
            <atom:updated>2024-07-21T05:04:31.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OvGVYtPQAYtF1Wqpcji1wg.jpeg" /><figcaption>Top of Mount St Helens’ crater, hike made possible by Ticket Bot.</figcaption></figure><p>TLDR; I explain how to make a ticket bot that checks for ticket availability every ~15 seconds and sends you a text and email when a ticket becomes available. I used this ticket bot to buy permits to climb Mount St. Helens. See the GitHub code <a href="https://github.com/blahner/ticket-bot">here</a>.</p><h3>Introduction</h3><p>Hiking an active volcano has long been on my bucket list. So when I spent a summer in Seattle, I set my eyes on hiking Mount St. Helens on the Fourth of July with a friend. As the date approached, however, I realized that the park service employs a permit system that sells out in mere minutes over a month before each date. There were zero permits available for the entire month, let alone July 4th.</p><p>Just when I thought all was lost, I saw a glimmer of hope: as I refreshed the permit availability page, I noticed spots sporadically opened and closed as hikers canceled their reservations and others bought them. Now I had hope that some permits might free up before the hike and I could snag some for my friend and I in time. But as much as I wanted to go on this hike, I just couldn’t dedicate the next week and a half refreshing the Mount St. Helens permit page. Enter, ticket bot!</p><p>In this post, I will walk you through how to make a ticket bot that automatically checks a website for ticket availability every ~15 seconds then sends you an email and text when a ticket becomes available. All code is available on my GitHub <a href="https://github.com/blahner/ticket-bot">here</a>.</p><h3>So what actually is a ticket bot?</h3><p>A ticket bot is simply code that automates exactly what you would do on a website. If you want a ticket bot to check for ticket availability on a certain date, for example, you would write code that navigates to the website, enters your desired date, and checks if your desired number of tickets are available — exactly the steps you would take.</p><p>Once the ticket bot sees that your desired number of tickets are available on your desired date, it can either complete the purchase for you (by again following the same steps you would take to complete the purchase) or notify you that the tickets are available. Here, I will show you how the ticket bot can send you an email and text notification when the tickets are available so you can manually complete the purchase.</p><h3>Building your ticket bot</h3><p>Since the ticket bot is going to automate everything we do, we naturally have to detail every step we would manually take to check for permit availability. In our example case of Mount St. Helens, the steps we (and the bot) would take are:</p><p>1. Navigate to the website URL in a browser</p><p>2. Enter number of permits you want (here, the ‘Group Members’)</p><p>3. Navigate to the correct month (here, ‘August’)</p><p>4. Check if permits are available for the desired day of the month (here, the 15th)</p><p>5. If permits are available: notify via email and text. If permits are not available: repeat starting with step 1.</p><p>Below is a pseudocode implementation:</p><pre># Imports<br>Import necessary libraries<br><br>Function check_permit_availability(group_size, month, day, year, url):<br>    Log the current time<br>    Setup and open a headless browser<br>    Go to the provided URL<br>    Wait for the page to load<br><br>    Try:<br>        Click the button to add group members<br>    Catch error:<br>        Log the error<br><br>    Try:<br>        If the desired month is in the future:<br>            Click to change the month<br>    Catch error:<br>        Log the error<br><br>    Format the desired date<br>    Try:<br>        Check if the desired date is available<br>        If available:<br>            Log availability<br>            Send email notification<br>    Catch error:<br>        Log that the date is not available<br><br>    Close the browser<br><br>Function send_email_notification(spots, date, url):<br>    For each email address:<br>        Send an email notification<br><br>Function main(args):<br>    Schedule the permit check to run periodically<br><br>    While True:<br>        Run scheduled permit check<br>        Wait for a short time to not overwork computer<br>        If an email was sent:<br>            Exit the loop<br><br>if __name__==&#39;__main__&#39;:<br>    Read the configuration file<br>    Set up email details<br>    Initialize logging<br>    Initialize email_sent flag<br>    Call main function with arguments</pre><p>The trickiest part in this code is identifying the html element that corresponds with an action on a website, like clicking a button. To do this, we hover over the part of the website that we would normally click on, but instead of a left click, we right click and hit ‘inspect’. This shows us the corresponding html. In the python code, you now need to refer to this specific html element and manipulate it. There are several ways to refer to the html element, but I find using its <a href="https://www.w3schools.com/xml/xpath_syntax.asp">XPath</a> is easiest and least error prone.</p><p>As an example, below I show a GIF of finding the html element corresponding to clicking the “+” button to increase the Group Members. Notice how hovering over the html element highlights the corresponding part of the website. Below that is the corresponding Python code to automatically “click” that html element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*S7dC5Pp0vPl_TQKB6MOc9g.gif" /><figcaption>GIF of finding the html element that corresponds to an action on the website.</figcaption></figure><pre>#open up chrome<br>options = webdriver.ChromeOptions()<br>options.add_argument(&#39;--headless&#39;)  # Run headless Chrome. comment out to see the browser actually open.<br>driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)<br>driver.get(url)<br><br>#find the Group Member &quot;+&quot; button and click it<br>group_button_xpath = &quot;//button[@data-component=&#39;Button&#39; and @type=&#39;button&#39; and contains(@class, &#39;sarsa-button&#39;) and contains(@class, &#39;sarsa-button-subtle&#39;) and contains(@class, &#39;sarsa-button-sm&#39;) and @aria-label=&#39;Add members&#39;]&quot;<br>group_button = driver.find_element(By.XPATH, group_button_xpath)<br><br>for _ in range(group_size):<br>    group_button.click() #click the plus button once</pre><h3>Putting it all together</h3><p>You will need to write Python code similar to above for each part of the website you would manually “click” or manipulate. But once that is done, you can run your ticket bot and see how it checks for ticket availability every ~15 seconds just like you would!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*i1O-FKiMDVthDIlPPANfBQ.gif" /><figcaption>This GIF shows the ticket bot automatically opening Chrome, navigating to the Mount St. Helens website, increasing the Group Members from zero to one, changing the month from July to August, and checking if there is availability on the 15th. Since there is no availability on the 15th, it closes the webpage and starts the process over again. If it had seen availability on August 15th, the bot would have sent you and email and text to notify you and closed out of the program.</figcaption></figure><p>Note that this ticket bot approach is pretty fragile. If the website modifies their html or implements some check to block automated visits, then you will have to find workarounds.</p><h3>And please don’t abuse ticket bots…</h3><p>Ticket bots are nothing new. Those who already know how to make them are already using them, and those who don’t know how to make them now have a great opportunity to learn a new tech skill that enables them to enjoy time outdoors or a night out with friends. Please don’t ruin someone else’s fun plans by buying more tickets than you need.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63c3d0706e92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boston’s Best Donut Shops Ranked (2024)]]></title>
            <link>https://medium.com/@benlahner/bostons-best-donut-shops-ranked-2024-55fa620c769d?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/55fa620c769d</guid>
            <category><![CDATA[foodies]]></category>
            <category><![CDATA[food]]></category>
            <category><![CDATA[boston]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[donuts]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Sat, 13 Jan 2024 21:18:10 GMT</pubDate>
            <atom:updated>2024-01-13T21:18:10.497Z</atom:updated>
            <content:encoded><![CDATA[<p>A local’s guide to Boston’s donut scene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*MaYUr9A8ylhMILgeNmXISg.jpeg" /><figcaption>Image source: <a href="https://www.pexels.com/photo/person-holding-doughnut-1865333/">https://www.pexels.com/photo/person-holding-doughnut-1865333/</a></figcaption></figure><h3>Boston’s Donut Scene</h3><p>Boston is home to a thriving donut scene with enough variety to satisfy any donut lover. Boston’s donut shops can be roughly divided into two categories, the “boujee” donut shops and “classic” donut shops. The “boujee” donut shops serve expensive, often outlandish donuts (think fruit loop donuts and donuts topped with Snickers) in modern style shops, appealing to the college crowd. The “classic” donut shops are your no frills mom and pop shops, the ones where you can get two donuts and a coffee for five bucks. Here I will rank eight of Boston’s most well known donut shops.</p><p>You may be asking, “Who are you to take on such a monumental task as ranking Boston’s donut shops?” And you are right, I do not claim to be worthy of such an honor, but after indulging in Boston’s donut scene for nine years across Boston proper, Allston, Cambridge, and Somerville, I think I can give it a good shot.</p><h3>Donut Ranking Metrics</h3><p>I rank the donut shops using a variation of a Cause and Effect matrix. The features of a donut shop I care most about are donut <strong>Taste</strong>, donut <strong>Price</strong>, <strong>Shop Vibes</strong>, and donut <strong>Variety</strong>, each given a “Priority Score” between 1–10. The priority score simply reflects how important I think each feature is in a donut shop and is used to weight each shop’s score (also between 1–10) in each feature. A shop’s final score, used for the final ranking, is the sum of the four feature ranks multiplied by each featur’s priority score.</p><p>Donut taste (priority score of 10) simply measures if the donut tasted good or not. Was it warm and fresh, or has it been sitting out on the counter all morning? I try to compare each shop’s standard glazed donut so as to measure more of their donut preparation process than any specific flavor.</p><p>Donut price (priority score of 8) measures how expensive the donuts are. If a shop scores high in this feature (e.g., a 10), that means the donuts are cheap.</p><p>Donut shop vibes (priority score of 5) reflect how comfortable or enjoyable a visit is for a customer. It does not necessarily measure how “nice” the store is. The location(s) is taken into account. Did you leave the donut shop with a smile on your face?</p><p>Donut variety (priority score 3) reflects how many flavors are generally available to a customer at any given time. Donut variety also includes gluten free options.</p><p>The detailed results are given in the table at the end of the post. Did I miss your favorite donut shop? Do you disagree with my ranking? Comment below! Also feel free to change the list of features, each feature’s priority score, or whatever to come up with your own ranking! Now for the moment we’ve all been waiting for…</p><h3>What is the Best Donut Shop in Boston?</h3><h3>1) Donuts with a Difference</h3><p>A true hidden gem, Donuts with a Difference is hands down the best donut shop in the greater Boston area. Located in a tiny storefront on an unassuming street in Medford, it would be easy to miss if it weren’t for its regular line extending down the sidewalk. Their hot, fresh donuts right out of the oven get a 10 for quality for a great price at just a little over a dollar. Paying in cash drives the price down a bit more. It gets a relatively low variety score because customers often pick up dozens of donuts at a time (a testament to their quality), thereby quickly destroying the selection, and their small kitchen space means they can only bring out so many donuts at once.</p><h3>2) Twin Donuts</h3><p>Situated right in the middle of busy Brighton Avenue and Cambridge Street in Allston, Twin Donuts has reliably provided early-rising locals with their donuts and coffee for decades. Although they have been forced to raise their prices recently, I believe they still serve the most inexpensive donuts on the list. They sell a decent variety of good quality donuts, and their retro diner vibes make it a great place to hang out on a weekend morning.</p><h3>3) Kane’s Donuts</h3><p>Of what I consider the “boujee” donut shops (Kane’s, Union Square, and Blackbird), Kane’s Donuts takes the cake. Their downtown location lets you enjoy your donut inside their nice shop, outside on the patio amidst the high rises, or on the nearby Greenway. Their donuts are more expensive than the previous shops on the list for not as good of quality (but still great), but they offer a great selection of regular and gluten free donuts. Kane’s is one of the more popular donut shops in Boston, often finding its way on conference tables in the surrounding office buildings.</p><h3>4) Doughboy Donuts</h3><p>Doughboy Donuts is an iconic Boston donut shop and deli best known for its 24/7 hours. It’s not located in the best or most exciting spot in town, but that only adds to its charm in an odd sort of way. Honestly, the quality of the donuts are just fine and the variety isn’t anything to call home about, but they are cheap. Hitting it up after a late night rock climbing session at nearby <a href="https://southboston.rockspotclimbing.com/">Rock Spot</a> is a must. It’s hard to explain, but you just have to give it a visit. Trust me.</p><h3>5) Union Square Donuts</h3><p>Tied for fifth place, Union Square Donuts is named after Somerville’s Union Square (my stomping grounds) and has since expanded to other locations throughout greater Boston. I highly recommend checking out Union Square for brunch then grabbing a donut to cap off the morning. The Union Square store has a small footprint, so it’s not great to hang out in, but it’s nice. They have a great variety of regular and gluten free donuts that they rotate through the seasons to keep things interesting. However, the donut quality is just fine and the price is high.</p><h3>5) Blackbird Doughnuts</h3><p>Blackbird Doughnuts, tied for fifth place with Union Square Donuts, is also one of the fancy and expensive donut (or doughnut??) shops in Boston. Like the other shops, the donuts are just okay quality sitting at room temperature on a shelf and expensive. Their variety is pretty good, and they have more interesting locations in Fenway, South End, and Beacon Hill. Overall, it’s a fairly meh experience with no big standout features.</p><h3>7) Donut Villa Diner</h3><p>Donut Villa Diner is new to the Boston area in the last few years. People usually go there for a full sit-down brunch, but, as the name suggests, they also have a good selection of donuts. They are fairly expensive for their quality, but the retro diner style is a fun throwback and always busy. Its main location is in Central Square, Cambridge, offering lots of fun things to do afterwards.</p><h3>8) Dunkin’</h3><p>I hate to be the one to say it, but someone has to. Dunkin’ Donuts may be as synonymous with Boston as Paul Revere, but their donuts are just not good. The taste is the worst on the list, their variety is always lacking, and the stores themselves are what you would expect from a fast food franchise. The only thing they have going for them is their cheap price. Nevertheless, Dunkin’ is a staple of Boston and is always there for you when you need a donut and coffee in a pinch. Thank you Dunkin’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*8OUPcFaYzkHLIiK09a9fEQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55fa620c769d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Curious George Discovers the Infinite Monkey Theorem]]></title>
            <link>https://medium.com/@benlahner/curious-george-discovers-the-infinite-monkey-theorem-652d73667229?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/652d73667229</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 17:16:13 GMT</pubDate>
            <atom:updated>2024-01-01T17:16:13.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*vl5NSZHH7uafjUwc" /><figcaption>Image generated by Stable Diffusion using the prompt, “A cartoon image of the monkey curious george hard at work typing on a keyboard.”</figcaption></figure><p>This is George. He wants to write a book. He ironically wants to call it, “Curious George Discovers the Infinite Monkey Theorem.” However, George is just a monkey — he doesn’t know how to write his name let alone an entire book. But he reasons that if he just randomly bangs on the keyboard for long enough then surely he can write his book!</p><p>After a year of random typing, the man in the yellow hat checks George’s progress to discover that he only typed the first five characters of the title, “curio”. George recognizes he cannot do this alone.</p><p>He recruits <a href="https://www.science.org/content/article/record-number-monkeys-being-used-us-research#:~:text=The%20total%20number%20of%20monkeys,see%20second%20graph%2C%20below)">100,000 of his smartest friends</a> gainfully employed in research facilities across the globe for help. After a full year of 100,000 monkeys randomly typing, the man in the yellow hat again checks their work to discover they have only written the first 9 characters, “curious g”. While the additional monkeys helped, George realizes they are going to need more time.</p><p>George negotiates a cagey employment contract with all his friends. In exchange for typing the rest of their <a href="https://genomics.senescence.info/species/entry.php?species=Macaca_mulatta">40 year lives</a>, they will receive a 1/100000 profit split on their completed book. 40 years go by, and the man in the yellow hat is excited to publish their much anticipated book. But to his dismay, the monkeys just barely managed to type, “curious geo” — hardly a best-seller! An <strong><em>additional 39 years</em></strong> of typing resulted in only <strong><em>two additional characters</em></strong> — “curious g” to “curious geo.”</p><p>But what if George and his friends were not limited by their 40 year life expectancies? How long would it take to finish their book? After 1.26x10⁶⁵ years, one of the 100,000 monkeys would have a 50% chance of randomly typing the full title, “curious george discovers the infinite monkey theorem” [1]. To type an entire children’s book of 4500 characters, they would need a whopping 1.02x10⁶⁷⁶⁰ years. These numbers are unfathomably large. Monkeys are thought to have first evolved 5.5x10⁷ (55 million) years ago, the age of the universe is 1.37x10¹⁰ (13.7 billion) years old, there are an estimated 1x10⁸² atoms in the universe — you get the idea.</p><p>It turns out George’s reasoning from the beginning was correct — according to the <a href="https://en.wikipedia.org/wiki/Infinite_monkey_theorem">Infinite Monkey Theorem</a>, he could write his children’s book — or any book — by randomly typing for a long enough amount of time. Unfortunately, that length of time happens to be near infinity.</p><p>Feel free to play with the <a href="https://github.com/blahner/curious-george">code</a> to vary the number of monkeys, how fast they type, the number of keys on the keyboard, etc.</p><p>[1] <a href="https://medium.com/@benlahner/what-is-the-probability-of-flipping-n-consecutive-heads-in-k-coin-flips-71fcae35c33a">Calculating the probability</a> of randomly typing even the title can take days on a normal computer. So to speed things up, I fit an exponential function to a handful of data points I did have the patience to compute. I fit the function f(x) = a*b^(x-c), where a= 7.639288944484754e-05, b= 32.00000045224133, c= 6.012772609139376.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=652d73667229" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Fundamentals of Neural Networks: A Comprehensive Tutorial Without Internet or GPUs]]></title>
            <link>https://medium.com/@benlahner/the-fundamentals-of-neural-networks-a-comprehensive-tutorial-without-internet-or-gpus-c6e65f5cb882?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6e65f5cb882</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Mon, 18 Dec 2023 01:10:27 GMT</pubDate>
            <atom:updated>2023-12-18T01:10:27.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZrQ6TUmhPVUKn7WopQoCw.jpeg" /></figure><p>Find the Fundamentals of Neural Networks tutorial on GitHub <a href="https://github.com/blahner/nntutorial-nogpu">here</a>!</p><h3>The Motivation</h3><p>A few years ago I started volunteering with <a href="https://www.teji.mit.edu/">The Educational Justice Institute</a> at MIT to teach Python programming to inmates around New England. Many of my students fell in love with Python and wanted to learn more advanced material, but they faced three main challenges:</p><p>1) Advanced material often requires <strong>internet access</strong> (e.g., documentation, package downloads, Stack Exchange).</p><p>2) TEJI and the correctional facilities do <strong>not have enough resources</strong> to teach an advanced course for only a couple students.</p><p>3)<strong> Computer hardware and computer access is limited</strong> in correctional facilities. The students must often work on outdated laptops within specific timeframes.</p><h3>The solution</h3><p>I chose to make a <a href="https://github.com/blahner/nntutorial-nogpu">tutorial</a> on neural networks because it was interesting to my students, a great followup to an introductory Python course, and a fun introduction to the power of machine learning. However, from my own experience learning about neural networks, a student often must piece together dozens of incompatible tutorials to make sense of a concept —<strong> I thought a single, unified tutorial on neural networks was lacking</strong>.</p><p>I made sure this <strong>self-guided</strong> tutorial <strong>does not require internet access</strong> after the initial material download and <strong>does not depend on GPUs</strong>. The tutorial is divided into five parts: <strong>(1) neural network overview, (2) neural network math, (3) coding a multi-layer perceptron (MLP) in NumPy, (4) coding a MLP in PyTorch, and (5) coding a convolutional neural network (CNN) in PyTorch</strong>. The variables used in the part 2 math explanation are kept the same in the part 3 NumPy MLP implementation. Parts 3, 4, and 5 all share the common task of MNIST classification but differ in framework (NumPy or Pytorch) and neural network architecture (MLP or CNN). <strong>In this way, new concepts are introduced while the old are being reinforced</strong>.</p><p>While I believe this tutorial addresses many challenges that existing neural network tutorials have, it is by far not the end-all be-all tutorial. I supplement each of the five parts of this tutorial with other resources that I had benefited from when learning. These resources include book chapters, math refreshers, PyTorch documentation, MLP tutorials, blog posts etc. If you know of a great tutorial or helpful resource you think I should add, please leave a comment!</p><h3>What makes this tutorial different from other tutorials?</h3><ul><li>Free</li><li>No dependence on GPUs or internet</li><li>Consistent variables between math and NumPy code</li><li>Heavily commented code</li><li>References to additional offline resources</li><li>NumPy code is directly comparable with PyTorch code to give a deeper understanding of what’s going on behind the scenes in PyTorch dataloaders, backpropagation, batching and more.</li><li>Weight and activation extraction and visualization in NumPy and PyTorch for both MLPs and CNNs</li><li>The three coding portions all share a common goal of MNIST classification but differ in framework (PyTorch or Numpy) and neural network architecture (MLP or CNN).</li></ul><h3>How to use this tutorial</h3><p>In a correctional facility setting, I think this tutorial can be most efficiently used if paired with a weekly 1-hour check-in with a volunteer tutor to check progress and answer any questions. It can be a great crutch for those looking to brush up on their neural network concepts and supplement other academic course material.</p><p><strong>The challenges this tutorial addresses are not unique to correctional facilities</strong> — many people have unreliable internet, bad computers, and would benefit from a comprehensive resource. Now more people can develop these fundamental computer science skills on the train commuting to work, traveling on an airplane, or simply at home offline.</p><p>You can access the entire tutorial — code, walkthrough PDF, material downloads — at <a href="https://github.com/blahner/nntutorial-nogpu">this GitHub link</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6e65f5cb882" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the probability of flipping N consecutive heads in K coin flips?]]></title>
            <link>https://medium.com/@benlahner/what-is-the-probability-of-flipping-n-consecutive-heads-in-k-coin-flips-71fcae35c33a?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/71fcae35c33a</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[coins]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 00:01:06 GMT</pubDate>
            <atom:updated>2023-12-11T00:01:06.209Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OduALpJxa0KPUkIdKkFnSA.png" /><figcaption>Image generated by Stable Diffusion.</figcaption></figure><p>What is the probability of flipping N consecutive heads in K coin flips? Now that you are all on the edge of your seats, let me explain.</p><p>We flip a coin with probability of success, p, and probability of failure, q (for a fair coin, p = q = 0.5). P(K) denotes the probability of flipping a run of N successes in K coin flips. In order to successfully achieve a run of N successes in K coin flips (P(K)), one of two scenarios must be true:</p><ol><li>You already flipped the run of N successes somewhere in the previous sequence of K-1 flips</li><li>You flip the run of N successes with the N’th successful outcome at flip K</li></ol><p>The union of scenario 1 and 2 equals P(K), the probability you achieve a run of N successes in K coin flips:</p><p>P(K) = P(scenario 1) + P(scenario 2)</p><p>Scenario 1 is straightforward to formulate. By definition, we say:</p><p>P(scenario 1) = P(K-1)</p><p>Scenario 2 is a bit trickier to formulate. But if we know the K’th coin flip was involved in the successful run, and the success was not found in the previous 1 to K-1 coin flips (otherwise we would be in scenario 1), we know three facts about the outcomes of the previous coin flips:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T0W57tmfFiBJf8Al" /></figure><p>Using N=3 as an example, we know the sequence of coin flips from 1 to K must look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IzdVP0MMDwrYZxM7" /></figure><p>The sequence of pink “?” from coin flip 1 to K-N-1 means we don’t know exactly whether the flip was a success (S) or fail (F), but just that there was <em>not</em> a run of N successes in that sequence. The probability that there was a run of N successes from flips 1 to K-N-1 is simply given by P(K-N-1), but since we want the probability of this <em>not</em> happening, we formulate it as 1-P(K-N-1).</p><p>The red “F” at flip K-N means that specific flip <em>must</em> have been a fail. If it were a success, the K’th flip would not have contributed to the run of N successes and we again would be in scenario 1, not scenario 2. This probability of the one fail is simply denoted as q.</p><p>The green “S” from flips K-N+1 (K-2 in this example with N=3) to K means those flips all had to be a success. This is formulated as the probability of success (p) N times in a row, or p^N.</p><p>We multiply the probabilities of the three terms to formulate scenario 2 as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zce0_Mx2EMJdr2qlR6EBfQ.jpeg" /></figure><p>Putting it all together, the probability of achieving a run of N successes in K coin flips is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_bYweUCizLtrhykZ18LUA.jpeg" /></figure><p>Note that this equation is recursive, so we have some base cases to fill in. When K &lt; N, P(K) = 0 because, for example, you cannot achieve a run of 3 successful coin flips in only 2 coin flips. When K = N, the probability is equal to p^N (the probability of a run of N successes in N coin flips means every flip has to be a success).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71fcae35c33a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Artificial General Intelligence Isn’t Coming Anytime Soon. Here’s Why.]]></title>
            <link>https://medium.com/@benlahner/artificial-general-intelligence-isnt-coming-anytime-soon-here-s-why-d29e6d9b90e6?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/d29e6d9b90e6</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[intelligence]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 00:49:51 GMT</pubDate>
            <atom:updated>2023-10-16T00:49:51.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="A consious robot" src="https://cdn-images-1.medium.com/max/768/1*BzJ5_t3vIMzHlv6GygeZ0A.png" /></figure><p>Artificial General Intelligence (AGI) feels just around the corner with ChatGPT transforming our daily lives and new state-of-the-art models introduced every week. With all of AGI’s promises and pitfalls, everyone seems to be holding their breath.</p><p>But feel free to let it out. It’ll be a while.</p><h3>What is Artificial General Intelligence?</h3><p>While the definition of AGI changes as the wind blows, I will define it here as a causal understanding of the world beyond just pattern recognition. It reflects a human-like ability to deeply understand and reason with the world around it.</p><p>Put another way, I would say Artificial Intelligence (AI) has achieved AGI when it achieves a similar status to a pet dog. We would have an emotional connection with it and it with us. Society would collectively believe in its autonomy, hold it accountable for its actions, and give it basic rights and protections.</p><h3>The Ingredients for Artificial General Intelligence</h3><p>Guided by the most advanced form of intelligence we know of, the human brain, I believe AGI requires at a minimum (1) a core statistical component and (2) a core causal component. Humans can accomplish a lot of daily tasks using statistics alone, such as completing basic sentences, following morning routines, and recognizing household objects. But humans additionally possess reasoning abilities rooted in an intimate causal understanding of our world. This causal reasoning allows us to solve complex arithmetic, empathize with others’ emotions, and answer counterfactual “what if” questions.</p><p>Are statistics and causality mathematically distinct, or can complex statistical inference and huge amounts of data achieve, or at least sufficiently mimic, causality? While people far smarter than me debate this, pioneering researchers Judea Pearl and Dana Mackenzie offer a convincing (and beginner-friendly) explanation as to how the mathematics of statistics and causality are distinctly different in their book <em>The Book of Why</em> [3]. You need causal mathematics to accomplish causal reasoning.</p><h3>The Current State of Artificial Intelligence</h3><p>The most advanced AI you hear about in the news is mathematically grounded in statistical pattern recognition, not causality. It is missing a core ingredient of AGI. While it truly feels like generative language models like ChatGPT have advanced human-like reasoning skills, I believe their impressive capabilities say more about the unexpected power of statistical pattern recognition than proximity to AGI.</p><p>The limitations of the current best AI models are like a chef given the leftovers of your fridge and asked to prepare a dish. Surpassing all expectations, the chef cooks a five course meal with a wine to pair, yet they will never be able to bake a chocolate cake. Why? <em>Because chocolate was never in your fridge! </em>Likewise, current AI models, despite their jaw-dropping results, cannot attain human-like intelligence because they were never given the “ingredients” to build causal relationships. Their algorithms are built for, and excel at, statistical pattern recognition, but not causality.</p><h3>Next Steps to Create AGI</h3><p>So this begs the question, if current AI models do not have the necessary components of AGI, do we need to scrap everything and start from scratch? Or can we continue to improve on current systems?</p><p>I am of the opinion that to attain AGI — and I do believe it will happen one day — we have to introduce causal algorithms. Like the human brain that relies on both pattern recognition and causality, I believe the first AGI system will have both a major pattern recognition component and causal component. So no, we probably do not need to scrap our current progress in AI, but yes, we do need to integrate causal mathematics. And such an integration will likely require a huge paradigm shift and scientific breakthroughs.</p><p>While more data, higher quality data, memory mechanisms, clever training schemes, multimodal integration, and a host of other approaches will definitely improve our current AI, I believe those features alone will never result in AGI.</p><p>For further reading, here are some arguments <a href="https://www.cambridge.org/core/journals/behavioral-and-brain-sciences/article/abs/deep-problems-with-neural-network-models-of-human-vision/ABCE483EE95E80315058BB262DCA26A9">why AI is nothing like the human brain</a> (Bowers et al., 2022) (while this focuses on the visual brain, I believe the arguments can extend to language and beyond). Here is an argument why AI, specifically GPT4, is an <a href="https://arxiv.org/pdf/2303.12712.pdf?utm_source=webtekno">early form of artificial general intelligence</a> (AGI) [2]. This is a <a href="https://www.amazon.com/Book-Why-Science-Cause-Effect/dp/1541698967/ref=sr_1_1?hvadid=241621363130&amp;hvdev=c&amp;hvlocint=1018145&amp;hvlocphy=9067723&amp;hvnetw=g&amp;hvqmt=e&amp;hvrand=4292913410459009719&amp;hvtargid=kwd-814458155&amp;hydadcr=22534_10353872&amp;keywords=the+book+of+why&amp;qid=1689360452&amp;sr=8-1">great book on causality</a> [3] for laymen written by pioneering researchers in the field.</p><h3>References:</h3><p>[1] Bowers, J. S., Malhotra, G., Dujmović, M., Montero, M. L., Tsvetkov, C., Biscione, V., … &amp; Blything, R. (2022). Deep problems with neural network models of human vision. Behavioral and Brain Sciences, 1–74.</p><p>[2] Bubeck, S., Chandrasekaran, V., Eldan, R., Gehrke, J., Horvitz, E., Kamar, E., … &amp; Zhang, Y. (2023). Sparks of artificial general intelligence: Early experiments with gpt-4. arXiv preprint arXiv:2303.12712.</p><p>[3] Pearl, J., &amp; Mackenzie, D. (2019). The book of why. Penguin Books.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d29e6d9b90e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Settling Disagreements with Trigonometry: Don’t Take Sides, Solve Them]]></title>
            <link>https://medium.com/@benlahner/settling-disagreements-with-trigonometry-dont-take-sides-solve-them-c8d14bff39c1?source=rss-ce5743796d92------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8d14bff39c1</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[beach]]></category>
            <dc:creator><![CDATA[Ben Lahner]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 19:57:15 GMT</pubDate>
            <atom:updated>2023-06-26T19:57:15.251Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aCzGj8AinxcXoGeC8jzkHQ.jpeg" /><figcaption>Photo of the island of Cayo Norte from Zoni Beach in Culebra, Puerto Rico. How far away is Cayo Norte?</figcaption></figure><p>“You think I can swim out to that island over there?”</p><p>My friend, Roman, pointing to the island of Cayo Norte (pictured above), whimsically asked the group if he could traverse the 3 miles of ocean water to the next island. Or so he thought it was 3 miles.</p><p>Another friend responded, “Yeah sure, it looks only half a mile or so away.” A frustrating debate ensued about the actual distance to the island. As the banter increased, we became determined to figure out who’s guess was closest. But how can we, sunbathing on a beach with no cell signal, actually find out who was right?</p><p>Enter trigonometry.</p><p>We reasoned that if we can form a triangle with two points on our beach and the third point on Cayo Norte, we can use trigonometry to solve all the triangle’s angles and side lengths with only a few measurements from our beach. By doing so, we find our distance to the island of Cayo Norte and see who was right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jnjik1UMIaYtOVB3BlgNzg.png" /><figcaption>Figure 1: Triangulation method to find distance to the island of Cayo Norte. Left: Photos from point A depicting the angle between sides B and C. Middle: Satellite image of Zoni Beach and Cayo Norte with a triangle overlaid connecting the points of interest. We want to solve for Side A (Sa), the distance between our beach setup and a point on Cayo Norte. Right: Photos from point B depicting the angle between sides A and C.</figcaption></figure><h3><strong>Making the Measurements</strong></h3><p>As depicted in Figure 1 (middle), we labeled point B as the location of our beach chairs and point A some arbitrary distance down the beach. We agreed to label point C as the lowest saddle point amongst Cayo Norte’s rocky hills. We chose some driftwood as a straightedge to carve the three sides of the triangle in the sand from points A and B (see Figure 1, left and right).</p><p>Next, we made three measurements: (1) the angle <strong><em>θA</em></strong> (Figure 1, left), (2) the angle <strong><em>θB </em></strong>(Figure 1, right), and (3) the side<strong><em> SC</em></strong>, the distance between points A and B. To measure the two angles, we took a photo of the lines carved into the sand and used our phone’s built-in photo cropper to find the angle. We determined the length of side <strong><em>SC </em></strong>by multiplying the number of steps between points A and B by our estimated stride length.</p><p>We measured:</p><p><strong><em>θA = 100°</em></strong></p><p><strong><em>θB = 74</em></strong>°</p><p><strong><em>SC = 268.5 meters (~0.167 miles)</em></strong></p><h3><strong>Solving the Triangle</strong></h3><p>With these three measurements, we could now solve the entire triangle! Since the angles of a triangle add to 180 degrees, we know the angle <strong><em>θC=180-θA-θB. </em></strong>Then we used the <a href="https://en.wikipedia.org/wiki/Law_of_sines">Law of Sines</a> to find the two missing side lengths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*jUR1l-a_ZOpco1uJ4DsdFg.png" /></figure><p>Specifically, to find side <strong><em>SB</em></strong>, the desired distance between our beach chairs and Cayo Norte, we calculated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*gssh26e-wR35YwN2pjg2oA.png" /></figure><p>To complete the triangle, we similarly found side <strong><em>SA</em></strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*v64tjMlbNWnLgPJtyAdNpA.png" /></figure><p>We plugged our measurements into the equations to find:</p><p><strong><em>θC = 6°</em></strong></p><p><strong><em>SA = 2,529 meters (~1.57 miles) *our measurement of interest*</em></strong></p><p><strong><em>SB = 2,469 meters (~1.53 miles)</em></strong></p><p>We determined that the distance between us (point B) and Cayo Norte (point C) is approximately 2,529 meters, or 1.57 miles!</p><h3><strong>Limitations of Our Beach Surveying</strong></h3><p>But how accurate is this method? While it all sounds good in theory, drawing lines in the sand and estimating stride length is definitely not very precise. Once we got back to our Airbnb with internet connection, we used Google Maps to find the true distance of 1,810 meters (~1.12 miles) between our beach chairs (point B) and Cayo Norte (point C), meaning we have an error of 39.7%.</p><p>Although our result could rule out the more extreme guesses, we could have still increased our accuracy in a number of ways while still only using our beach tools. We recognize the accuracy of this triangulation method is significantly affected by <a href="https://en.wikipedia.org/wiki/Abbe_error">Abbe error</a>, meaning a small error in an angular measurement (i.e., measuring our <strong><em>θA</em></strong> and <strong><em>θB)</em></strong> magnifies over distance. For example, if we would have measured <strong><em>θA = 99° </em></strong>and <strong><em>θB = 73° — </em></strong>just 1 degree less than our real measurement — our result would have been 1,906 meters, or an error of just 5.3%. Thus, fixing either <strong><em>θA </em></strong>or <strong><em>θB </em></strong>to be 90<strong><em>°</em></strong> with a manufactured object (e.g., the frame of a beach chair) and averaging <strong><em>θA</em></strong> and <strong><em>θB </em></strong>across each friend’s individual measurement would have greatly reduced error. Additionally, making point C a well-defined structure on the shoreline and measuring <strong><em>SC </em></strong>with a consistent tool (e.g., a section of a rope) instead of highly variable stride lengths would have provided more reliable estimates.</p><p>All told, it was fun to solve a seemingly impossible task — measuring a distance over an ocean — with tools you bring to a beach.</p><p><strong><em>Note:</em></strong><em> When I first wrote this article, I surprised myself at how boring it was. So I spiced it up a bit (read embellished) in the article titled, </em><a href="https://medium.com/@benlahner/a-new-angle-on-the-legend-of-cocaine-island-7791f7049f36"><em>“A New Angle on the Legend of Cocaine Island.“</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8d14bff39c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>