<?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 Ana Maria on Medium]]></title>
        <description><![CDATA[Stories by Ana Maria on Medium]]></description>
        <link>https://medium.com/@anamaria_69121?source=rss-5e1b0396b421------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MX3O1u3NaTVJOhTZ</url>
            <title>Stories by Ana Maria on Medium</title>
            <link>https://medium.com/@anamaria_69121?source=rss-5e1b0396b421------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:25:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anamaria_69121/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[Dealing with False Positives]]></title>
            <link>https://medium.com/anybrain/dealing-with-false-positives-ef6ca06c1b85?source=rss-5e1b0396b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef6ca06c1b85</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[false-positive]]></category>
            <category><![CDATA[anticheat]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[games]]></category>
            <dc:creator><![CDATA[Ana Maria]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 09:35:53 GMT</pubDate>
            <atom:updated>2026-06-25T14:09:15.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZbLStjZcAHbrgH5Lhra5Qw.png" /></figure><h3>The False Positive Trap</h3><h3>Intro</h3><p>False positives matter more than most people think. In a crime investigation, accusing an innocent person can be just as damaging as missing a guilty one. A false accusation destroys trust, damages credibility, and can permanently affect the victim. The goal is not simply to catch offenders; it’s to catch only offenders.</p><h3>Section 1: The Crime Scene Is Messy</h3><p>If you walk into a crime scene and expect a clean trail of clues, you’ve already failed as an investigator. Real-world data is noisy and context-dependent. To build a solid case, we must first curate our evidence.</p><h3>1.1 Are the witnesses reliable?</h3><p>Let’s say that your labels are our witnesses. If the labels point at innocent people and swear they’re the culprit, then your model learns that ‘innocent’ looks like ‘guilty’. False positives start here!</p><p>But the opposite is just as dangerous: if real culprits are slipping into your “innocent” pile undetected, your model’s boundary becomes warped in the other direction. It learns to accept bad behaviour as “normal,” leading to False Negatives, where you miss actual threats entirely.</p><p>Audit your data! Manually check a random sample. If you find a bad witness or a mislabeled suspect, kick them out of the dataset. You cannot build a fair verdict on a foundation of perjured testimony.</p><p>To illustrate this concept, imagine the following scenario: imagine your model is looking at call patterns to catch scammers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PqGe6BHzyC1ScNzl2SxE4A.png" /></figure><p>If you accidentally label a busy pizza shop as a “scammer,” the model begins to think that high call volume is a sign of guilt. It then draws a “guilty” boundary that unfairly flags every busy, legitimate business as a scam operation.</p><p>Conversely, if a real scammer hides near an incorrectly labelled “innocent” data point, the model will learn to ignore them. In short: if your training data is tainted by errors, the model will treat those mistakes as the “law,” causing it to falsely accuse the innocent and overlook the guilty.</p><h3>1.2 The City Isn’t 50% Criminal</h3><p>In a city of a million people, you don’t have 500,000 burglars (hopefully!). Most datasets shouldn’t be a 50/50 split between innocents and criminals in a dataset. It isn’t real, it doesn’t describe the real case scenario.</p><p>If you force a perfect balance, you create a paranoid model that arrests people for sneezing. Keep your validation data as imbalanced as the real world. Use techniques like SMOTE or Class Weights to help the model recognise rare crimes, but don’t erase the natural bias toward innocence.</p><h3>1.3 Don’t Profile the Wrong Neighbourhood</h3><p>If you only analyse behaviour from suburban families, you’ll probably flag night shift workers just because their schedule is different. To avoid ‘narrow data’, your training data should represent:</p><ul><li>different users</li><li>different environments</li><li>different behaviours</li></ul><p>Because you never know where the culprit might be hiding.</p><h3>1.4 Ignoring the Red Herrings</h3><p>A detective shouldn’t care if a suspect is wearing a blue shirt if 98% of the city also wears blue shirts. That’s a red herring. In data, we call these unstable features. If a feature is common to everyone, like ‘uses a telephone’, it provides no insight into who is a scammer. However, do not discard noise blindly. Understanding the cause is vital, as some missing values are actually informative. Rather than deleting unstable features that fluctuate wildly, use techniques like regularisation to penalise extreme sensitivity.</p><p>Imagine you include a feature that is common to everyone, like ‘Uses a telephone’. This tells you nothing about who is a scammer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ufxkZXqFeRcvUkyAMGXNg.png" /></figure><p><strong>‘Uses a Telephone’</strong> is your <strong>Red Herring</strong>. Everyone in this investigation uses a telephone! If your model spends its ‘computational budget’ trying to analyse that feature, it’s ignoring the real evidence (like <em>New Addresses</em> or <em>Call Duration</em>). It’s the data equivalent of a detective focusing on the fact that the suspect was wearing shoes. It’s technically true, but it doesn’t help you solve the crime.</p><h3>Section 2: The Art of the Threshold</h3><p>Setting a threshold is the moment you move from <em>investigating</em> to <em>arresting</em>. If the bar is too low, you drag innocent people to the station; too high, and the guilty walk away.</p><h3>2.1 The “Heavy Tail” of Human Behaviour</h3><p>While in a ‘normal’ sample, most people have a somewhat steady and predictable routine, some might be eccentric: they work weird hours or travel constantly. If you set an arrest threshold based on ‘maximum normal behaviour plus a tiny margin’, you criminalise anyone who is simply out of the ordinary.</p><p>We can visualise this idea as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVrUXClUcAXCAfCswBZNgA.png" /></figure><p>The red line is the “naive detective.” It catches the scammers, but it also drags in all those “heavy tail” innocent users who just happen to be power users. A better detective adjusts the threshold to the right, or better yet, uses individual baselines.</p><h3>2.2 Dynamic Standards</h3><p>You can’t apply the same standard of evidence to a part-time teenager working in a local grocery store, saving up for a PS5, as we do to a K-pop idol. A 10,000€ transfer is a major red flag for a teenager, but just a regular Tuesday for a global star.</p><p>In some cases, you might require dynamic thresholds. You should judge a suspect against his own personal ‘baseline’, not the city-wide average. If a suspect’s behaviour is 3x their own personal norm, that’s evidence; if it’s just 3x their neighbour’s, it might just be a different lifestyle.</p><h3>2.3 Sequence vs Snapshot</h3><p>Is a man running down the street fleeing a crime or catching a train? A single data point (a snapshot) lacks context. To get a warrant, you need the sequence. Don’t base an arrest on one event. Instead, look for the progression: (1) Loitering near property → (2) Searching for security cameras → (3) Attempting multiple entry points.</p><h3>2.4 The “Multi-Clue” Requirement</h3><p>In court, circumstantial evidence is rarely enough. Combine signals: <em>Magnitude + Stability</em> (high activity with robotic consistency) or <em>Speed + Regularity</em> (fast actions with perfectly uniform timing).</p><p>The figure below shows a simplified representation of this process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRhQgKSMA6xm1aXQrysGuw.png" /></figure><p>In a phone scam, a single high-value transfer isn’t enough to flag someone. If you only look at ‘Speed’, you catch some fast-talking salespeople. If you only look at ‘Consistency’, you catch some automated background tasks. But when you look at the Red Cluster (High Speed AND Low Variance), you’ve found a phone scam operation. That overlap is your ‘probable cause’.</p><h3>2.5 The Detective + The Law</h3><p>A machine learning model is like an informant: it’s incredibly good at spotting patterns we might miss, but it doesn’t always understand the law. A rule-based system is our ‘Law Book’, and with it, we define the non-negotiables.</p><p>Some of the strongest investigations use a hybrid system. The model flags the potential suspect, but the ‘Rules’ act as the final review before an arrest. This ensures that every flag has a logical, human-readable justification that would hold up in a courtroom.</p><h3>Section 3: The Danger of “Snap Judgments”</h3><p>Convicting someone based on a glance is the fastest way to ruin an investigation.</p><h3>3.1 The “Non-Negotiable” Minimum</h3><p>In a courtroom, if the prosecution has zero evidence, the judge dismisses the case. In your model, you need to enforce the same rule.</p><p>If a user hasn’t performed a minimum number of events or existed in the system for a minimum time window, you shouldn’t even score them. It’s better to have a ‘blind spot’ for a few hours than to flag an innocent new user as a criminal just because you lack their baseline.</p><h3>3.2 The Law of Large Numbers</h3><p>With few data points, the variance is steep and misleading. Plot variance against sample size. Only trust features where the variance has levelled off. This is the point where the ‘noise’ of daily life averages out.</p><h3>3.3 The Smoothing Dilemma</h3><p>Smoothing is like interviewing a witness three times to ensure their story is consistent. It irons out the jittery spikes that don’t really matter.</p><p>However, you have to be careful. If you smooth everything, you’ll erase the very crime you’re trying to solve.</p><ul><li><strong>When to Smooth: </strong>Imagine you are monitoring the “Average Login Frequency” for an account. A user might log in 5 times one day and 15 times the next because they are busy. A single spike here isn’t a crime; it’s just life. By using a moving average (smoothing), you filter out these day-to-day jitters and establish a steady baseline. You only raise the alarm if the smoothed average remains abnormally high for an extended period.</li><li><strong>When NOT to Smooth:</strong> Imagine you are tracking a “System Configuration Change” event. A user suddenly disables multi-factor authentication (MFA). This is a binary, high-impact event. If you use a moving average to “smooth” this data, you might average it out with 10 previous days of “no change,” effectively muting the alert because the “average” change remains low. In this case, you do not smooth. You want to detect that single, sharp spike immediately.</li></ul><p>Let’s see what that looks like in practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSLzI_3xvu858qTI9EPMpw.png" /></figure><p><strong>The Blue Plot:</strong> Show how smoothing is your friend when dealing with natural fluctuation. It prevents you from overreacting to a busy Tuesday.</p><p><strong>The Red/Orange Plot:</strong> Show how smoothing is your enemy when dealing with binary threats. If you smooth the red line, the orange dashed line hides the severity of the security breach, turning a “critical emergency” into a mere “minor blip.”</p><h3>Section 4: The Serial Offender</h3><p>If a suspect runs through a red light, it might be an emergency or a distraction. But if they run ten red lights in a row, it’s more than that, and a high-speed chase is justifiable.</p><p>The biggest mistake a “detective” (model) can make is reacting to a single, isolated spike. Real criminal intent is rarely a momentary flash, it is a sustained pattern.</p><h3>4.1 The Continuity Rule</h3><p>To filter out one-off mistakes, use a continuity rule. Trigger an alarm only if you see <em>N</em> anomalies in a window, or if an anomaly persists for <em>X</em> minutes.</p><h3>4.2 The Detective’s Log</h3><p>In the previous chapter, we talked about smoothing data to understand a suspect. Here, we smooth the <em>verdict</em> to ensure we aren’t being impulsive. Think of this as the detective reviewing the entire case file before finalising the arrest report. For example, we can use:</p><ul><li><strong>Sliding Window:</strong> Aggregate scores over time. If the average score crosses the threshold, the case is serious.</li><li><strong>EWMA (Exponentially Weighted Moving Average):</strong> This prioritises recent behaviour while keeping history in mind. It keeps you reactive to new threats while remaining steady enough to ignore random noise.</li></ul><p>Think of it as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEbzQtZTGcZar_MFMTN2eA.png" /></figure><p>The <strong>grey line (Raw Risk Score)</strong> represents a series of individual snapshots. If you were to arrest based on this alone, you might catch a real offender, but you would also be constantly distracted by the “wobbles” of daily life.</p><p>The <strong>red line (EWMA Verdict) </strong>is your detective’s logbook. It ignores the short-lived, jagged spikes in the grey line (temporary noises). Instead, it only rises steadily when the suspicious behaviour is sustained.</p><p>When the red line finally crosses the <strong>black dashed Arrest Threshold</strong> around the 14-minute mark, it isn’t reacting to a single moment. It is proving that the suspect has been active long enough to build a clear, persistent pattern of behaviour. This is the difference between guessing and building a case: you aren’t just reacting to a bad minute; you are documenting a bad hour.</p><h3>Section 5: The Contextual Jury</h3><p>As mentioned before, in a courtroom, context is very important.</p><p>This is the final hurdle in reducing false positives: Context. An anomaly is just a deviation from a norm, but a crime is a deviation from the rules.</p><h3>5.1 Adding Context as Evidence</h3><p>By adding features like device type, environment, or platform, you turn a ‘new device’ event from a red flag into a harmless, explainable log entry.</p><h3>5.2 Same Signal, Different Meaning</h3><p>Identical metrics can stem from vastly different intentions. A user who performs 50 actions a minute might be a high-frequency attacker or a power user using keyboard shortcuts.</p><p>Without context, your model is forced to guess. By providing contextual metadata, you turn a vague ‘anomaly’ into an explainable behaviour profile.</p><h3>5.3 Controlled Data Collection</h3><p>Ensure your training set contains both ‘normal’ and ‘anomaly’ data within the same conditions. If you only show the model’s normal behaviour from public transport and ‘anomaly’ behaviour from a car, the model will mistakenly learn that cars are suspicious. You have to show both types in both contexts to force the model to learn the difference between the device and the intent.</p><h3>5.4 The “Impossibility” Check</h3><p>Even the best models can be fooled. This is why you must implement impossibility checks, that is, hard rules that override the model.</p><p>For example, a suspect logged in from London, then 30 seconds later from Tokyo. This is physically impossible. Combining these ‘sanity checks’ with your model creates a layered defence. If the model thinks it’s suspicious, but the impossibility rule says it’s physically impossible for the person to be the owner of the account, you have a much higher confidence level for your verdict.</p><h3>Section 6: The Internal Audit</h3><p>If you ignore your false positives, you are doomed to repeat them. False positives are not random accidents; they are structured patterns. If you flagged an innocent night-shift worker as a criminal just because of the schedules, they actually represent a blind spot in your ‘law’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QhQbtqKiiN2lxf5sveob8w.png" /></figure><h3>Section 7: Choosing Your Detective</h3><p>Choosing a model is like hiring a team of investigators. You want investigators who are smart, disciplined, and don’t jump to conclusions.</p><h3>7.1 Hire the Right Expert</h3><p>For most anomaly detection, Random Forest, XGBoost, and LightGBM are your top candidates.</p><p>They handle non-linear relationships (the ’if-this-then-that’ scenarios) and are less sensitive to feature scaling than linear models. Models like LightGBM and XGBoost are highly efficient because they use histogram-based splitting, making them perfect for both massive datasets and smaller, niche investigations where you need a quick, reliable decision.</p><h3>7.2 Don’t Let the Model Overreact</h3><p>You must prevent your model from ‘memorising’ the training data (overfitting), which inevitably leads to unpredictable errors and a spike in false alerts.</p><p>To keep the model grounded, control <em>max_depth </em>to stop the model from building overly complex, nonsensical rules. If using gradient boosting, the <em>learning_rate </em>is your precision dial, so you can lower it to ensure the model learns slowly and carefully.</p><p>Use ensemble methods. Instead of relying on one ‘witness’, use Stacking or Voting to combine multiple models. When one model is ‘paranoid’, the collective ensemble averages out the bias.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLIoQuKqYw0VQiPUS0JDDQ.png" /></figure><h3>7.3 Data Hygiene: The Foundation of Justice</h3><p>The best model in the world will fail if you feed it biased data. Before you train, consider these practical requirements:</p><ul><li><strong>Feature Quality &amp; Outliers:</strong> While tree-based models like XGBoost and LightGBM are scale-invariant (meaning they don’t require feature normalisation), they remain highly sensitive to extreme outliers and noise. Cleaning your data isn’t about scaling ranges, but it’s about signal quality. Always scrub your features for noise and bias to ensure your “detective” is focusing on real evidence rather than anomalies in the data itself.</li><li><strong>Handling Missing Data:</strong> Know your tool’s relationship with NaN values. Tree-based models (XGBoost/LightGBM) are sophisticated enough to treat NaN as a meaningful category, where in many cases, the absence of data is a signal itself. This is a massive advantage over Neural Networks, which require you to manually deal with missing values.</li><li><strong>Managing Imbalance:</strong> Use undersampling and oversampling techniques to ensure the model respects the rare “criminal” class without hallucinating crimes in your normal population.</li></ul><p>To illustrate this concept, imagine the following scenario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8KHsZ_oM-1bNt-RJr_N15Q.png" /></figure><p>The <strong>Left Plot</strong> shows the detective the “crime scene” (99% Innocent, 1% Criminal), with the tiny red cluster being hard to find.</p><p>The <strong>Right Plot</strong> (The Confusion Matrix) is the smoking gun. Look at the bottom-right corner. It shows 0 True Positives. The model looked at 10 criminals and didn’t arrest a single one. Even though the model is technically “99% accurate,” it is 100% useless at its actual job.</p><p>Don’t let accuracy fool you. If your data is imbalanced, your model will take the easy way out. It will label everyone ‘innocent’ to maintain high accuracy. Use this confusion matrix to see the truth: if your model isn’t catching the minority class, it isn’t an investigator, it’s a broken system.</p><h3>The Verdict</h3><p>Reducing false positives isn’t about being lenient: it’s about being precise. An investigation that relies on brittle thresholds doesn’t catch cheaters. Instead, it drags honest citizens into the station. We believe player trust is too important to risk. At Anybrain, we prioritise that trust.</p><p>We treat every false positive as a critical learning opportunity, feeding those mistakes back into our models to sharpen our ‘detectives‘ intuition. Cheating is rarely a one-time event. More often, it is an escalation. We have the advantage of time. Every second a player is in our system, they are being evaluated. Eventually, that cheater will push too far, and when they do, we will be ready.</p><p>Our goal isn’t to cast a wide net. It is to build an evolving defence that grows stronger with every case. At the end of the day, the goal remains the same: Catch the offender, protect the honest player, and never mistake noise for justice.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef6ca06c1b85" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anybrain/dealing-with-false-positives-ef6ca06c1b85">Dealing with False Positives</a> was originally published in <a href="https://medium.com/anybrain">Anybrain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum Quest: An RPG Tale of Superposition and Entanglement]]></title>
            <link>https://medium.com/anybrain/quantum-quest-an-rpg-tale-of-superposition-and-entanglement-307b18530162?source=rss-5e1b0396b421------2</link>
            <guid isPermaLink="false">https://medium.com/p/307b18530162</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[gaming]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Ana Maria]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 10:39:13 GMT</pubDate>
            <atom:updated>2025-07-09T13:32:22.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oI7_px0u1CcilOyuLxepdQ.png" /></figure><p>Imagine you’re playing an RPG. Your character, let’s name him Nuno, gets to a crossroads, and you have two possible roads to follow: path A, a dark forest or path B, a rocky mountain. You can only choose one, but you can explore each path before deciding. In classical computing, Nuno can only explore one path at a time. You could start by exploring path A first, gathering data, bosses fought, loot found, traps fallen, and return. Then you explore path B, gather more data, and compare. This works, but exploring one at a time is time-consuming, and resources are limited! And now imagine if it were 100 different paths, exploring each one <strong>sequentially </strong>would be a serious grind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*XyTLlQow27xxBWqj" /></figure><p>But, what if we are not in a classical environment? What if your character has a special ability called <strong>superposition</strong>, which allows them to exist in <strong>multiple realities at once? </strong>Instead of exploring one path at a time, your character “splits” across all paths simultaneously. Now, with this ability, we can gather all the data we need in a fraction of the time! Also, in this version, you have a travel companion, named Carlos, and both Nuno and Carlos are <strong>linked</strong>. If Nuno finds a healing potion recipe, Carlos will also benefit from it. If Carlos falls into a trap, Nuno will adjust the course without even having to see Carlos in the trap. This is <strong>entanglement</strong>,<strong> </strong>in the state that the duo shares knowledge instantly, which improves the decision-making of the duo.</p><p>This teamwork means that they are evaluating all paths in <strong>parallel</strong>, like exploring every single quest of a storyline <strong>at the same time</strong>. This not only makes the decision process much faster but also more informed. So, now you’re at a point where Nuno’s and Carlos’ experiences interact and <strong>interfere </strong>with each other. Where successful paths, with high rewards, reinforce each other, and low-rewards or dead ends cancel each other out. In the end, when Nuno makes a final choice, it won’t be random; you won’t forget path number 75, or mix path number 2 with path number 6, all paths are weighted in this final choice, which is the most promising path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*3523tL1nUGu1gXlO" /></figure><p>Superposition, entanglement, parallelism and interference are some of the key phenomena that make quantum computing so different from classical computing. Not only is it faster, but smarter, more optimised for decision-making and better suited to scale with increasingly complex problems, like, what if we had 1000000 paths!</p><p>Of course, these phenomena have been simplified to fit within the RPG example. In reality, they involve complex mathematics and physics, which we won’t discuss here. The objective is just to give a feel for how differently quantum computing works from classical computing.</p><p>So, how does this matter in data science? Let’s think of every decision our RPG has to make as optimising models, searching for patterns, choosing model features, and many others. We can see how beneficial quantum computing would be for data scientists, who often have to deal with massive and complex problems. And, let’s be honest, classical tools struggle with high-complexity problems. This is where quantum computing shows promise, enhancing our ‘toolbox’ for the kinds of data challenges that are becoming too big for classical methods.</p><h3>Treasure Hunting with Quantum Tricks</h3><p>Let’s see this advantage through a practical example, still using our gaming analogy.</p><p>Imagine we have 32 paths, and only one of them hides a treasure. The rest are empty. This is a classic search problem, and to solve it, we can take two strategies: a classical brute force search, or a quantum search, using Grover’s Algorithm.</p><h4>The classical Brute Force</h4><p>In the classical approach, we search each path one at a time. In the worst-case scenario, there’s a possibility that we have to search all paths. This means we might have to check all 32 paths to find the path we want. So, for N possible paths, this strategy takes O(N) time.</p><h4>Quantum Grover’s Algorithm</h4><p>On the other hand, Grover’s algorithm can find the correct path in only <strong>√</strong>N steps! For 32 paths, this is about ~6 steps. Therefore, for N possible paths, it would only take O(<strong>√</strong>N).</p><p>To better understand the logic behind Grover’s search, let’s simplify the problem: suppose we know the exact path code we’re looking for, we just need to search for it within a list of possible paths? Imagine each path name is defined as a unique combination of 1’s and 0’s, like ‘01001’ — in quantum computing, such binary strings correspond to quantum states, represented in Dirac notation, just like |01001⟩. <br>For the brute-force approach, it is very straightforward, as the name suggests. We check each path; if it is what we want, it stops!</p><p>But, for Grover’s algorithm, it is not that simple. Remember reading about superposition, interference and entanglement in the intro? Well, that is what makes it fundamentally quantum!</p><p>We start with creating a <strong>superposition </strong>of all possible states, which means the quantum system is in a mix of all N paths at once (something only quantum computers can really do).</p><p>In the next step, we create a function called <strong>oracle</strong>, which is a quantum function that marks the path we want by flipping the sign of the state (our path name). For example, in classical terms, it’s like a function <em>f(x)</em> that returns 1 if <em>x</em> is what we are looking for, and 0 if otherwise. In the quantum version, we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/0*ziG-NoIfhynxxggI" /></figure><p>This function sets up <strong>interference </strong>for the next phase, called the diffuser. In this step, it uses interference to amplify the probability of the states that correspond to the wanted solution, and fades the ones that do not.<br>It then proceeds to repeat the previous steps, for about N times. By repeating, it increases the probability of the correct path. Finally, the quantum system is measured, and it returns the solution state, with a high probability of being the path we were looking for!</p><pre>from qiskit import QuantumCircuit, transpile<br>from qiskit_aer import Aer<br>from math import floor, pi, sqrt<br>import time<br>import matplotlib.pyplot as plt<br><br>def diffuser(n):<br>  # This function creates a diffuser gate for Grover&#39;s algorithm<br>  # This gate boosts the probability of measuring the correct path<br><br>  diff = QuantumCircuit(n) # Create a quantum circuit with n qubits<br>  # Perform some quantum gate actions that make up the diffuser<br>  diff.h(range(n))<br>  diff.x(range(n))<br>  diff.h(n-1)<br>  diff.mcx(list(range(n-1)), n-1)<br>  diff.h(n-1)<br>  diff.x(range(n))<br>  diff.h(range(n))<br>return diff<br><br>def phase_oracle(n, target_index):<br>  # This function creates the oracle, the gate that marks the correct answer<br>  # It flips the sign(phase) of the target state<br>  # The marking helps the diffuser know which answer to amplify.<br><br>  oracle = QuantumCircuit(n)<br>  binary = format(target_index, f&#39;0{n}b&#39;) # Converts the target to binary (e.g., &#39;111&#39;)<br>  for i, bit in enumerate(binary):<br>    if bit == &#39;0&#39;:<br>      oracle.x(i) # Apply a flip<br>  oracle.mcx(list(range(n-1)), n-1) # Marks the target<br>  for i, bit in enumerate(binary):<br>    if bit == &#39;0&#39;:<br>      oracle.x(i) # Undo the flips<br>return oracle<br><br>max_qubits = 20 # Set maximum number of qubits, in this case to run the Grover&#39;s algorithm for 2 to 20 qubits (search space)<br>backend = Aer.get_backend(&#39;qasm_simulator&#39;) # Get a virtual quantum computer (a simulator)<br>brute_steps = [] # Array to save the number of steps with the brute force approach<br>grover_steps = [] # Array to save the number of steps with Grover&#39;s algorithm<br>simulation_times = [] # Array to save how long the quantum simulation took<br><br># For each number of qubits from 2 to max:<br>for n in range(2, max_qubits + 1):<br>  N = 2**n # Total number of possible paths<br>  target = N - 1 # Set the target as the last item ( to test the worst case scenario)<br>  num_iterations = floor((pi / 4) * sqrt(N)) # Calculate number of Grover steps<br>  <br>  # Create a quantum circuit<br>  qc = QuantumCircuit(n)<br>  qc.h(range(n)) # Initialise in superposition (put the system into a state of equal possibility)<br>  <br>  oracle = phase_oracle(n, target) # The gate that marks the correct answer<br>  diff = diffuser(n) # The gate that amplifies it<br>  <br>  # Repeat the process<br>  for _ in range(num_iterations):<br>    qc.append(oracle.to_gate(), range(n))<br>    qc.append(diff.to_gate(), range(n))<br>  qc.measure_all() # Measure the result<br><br>  # Simulate and time how long it takes<br>  start = time.time()<br>  compiled = transpile(qc, backend)<br>  result = backend.run(compiled, shots=1024).result()<br>  end = time.time()<br><br>  counts = result.get_counts() # Count how often each answer came up<br>  simulation_times.append(end - start)<br>  brute_steps.append(N)<br>  grover_steps.append(num_iterations)<br><br># Draw a graph showing how many steps each method took<br>plt.figure(figsize=(12, 6))<br>plt.plot(range(2, max_qubits+1), brute_steps, label=&quot;Brute-force steps (O(N))&quot;, marker=&#39;o&#39;)<br>plt.plot(range(2, max_qubits+1), grover_steps, label=&quot;Grover steps (O(√N))&quot;, marker=&#39;s&#39;)<br>plt.xlabel(&quot;Number of Qubits&quot;)<br>plt.ylabel(&quot;Steps&quot;)<br>plt.legend()<br>plt.grid(True)<br>plt.tight_layout()<br>plt.show()</pre><p>We’ve seen the basic idea behind Grover’s algorithm, but how does it perform as the number of paths grows?</p><p>Let’s look at the performance difference between the classical and quantum approaches mentioned above. In the plot below, we compare the number of steps each method takes as the number of ‘paths’ increases.</p><p>The blue line represents the brute-force performance, and the orange line represents the Grover’s algorithm performance. The blue line grows exponentially with the number of paths; on the other hand, the orange line grows much more slowly! At 220 paths, the brute-force needs over 1 million steps, as for Grover’s algorithm only needed about 1000 steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*7IOuqzZnQzPobimK" /></figure><h3>Quantum Advantage: What’s Real, What’s Next?</h3><p>This is one of the examples where we can see the quantum advantage in action! Other algorithms play the same advantage, in different fields. For example, in cryptography and data security, we have Shor’s algorithm that can factor large numbers exponentially faster than popular classical algorithms.</p><p>And what about data science? Quantum computing holds a promising future here! Many problems in data science involve dealing with big datasets, finding patterns in high-dimensional spaces, and optimising models. All of these are tasks where we can see that quantum algorithms could provide an edge.</p><p>Not only can quantum computers process big amounts of data much faster than classical computers, but we also have Quantum Machine Learning algorithms, like Quantum Principal Component Analysis and Quantum Neural Networks. We also have Quantum Optimisation Algorithms that are used to solve optimisation problems, etc.</p><p>Even though we are in early stages, we can see the potential!</p><p>Of course, all of this comes with challenges. One of the biggest challenges is hardware. Current quantum computers are still limited and prone to errors, which restricts the complexity of problems they can process.</p><p>We do have advanced quantum computers developed or being developed by IBM, Google, among others. For example, IBM Quantum Eagle has 127 qubits — fundamental units of quantum information, similar to classical bits but with a very different behaviour. These qubits are extremely fragile and easily disrupted by external factors and other quantum phenomena, causing errors to accumulate during computation.</p><p>And while 127 bits may sound impressive, it is still quite limited for most quantum algorithms! To outperform classical systems on meaningful problems, we would likely need thousands to millions of qubits.</p><p>Beyond hardware, there’s also the challenge of developing the algorithms. Many quantum algorithms still remain on a theoretical basis. Developing them is non-trivial: it requires new ways of thinking about problems, new mathematical tools, and a whole new, unfamiliar logic!</p><p>In addition, quantum algorithms don’t always perform better than classical ones. They often only show an advantage when the data is very large and complex — that’s where they really shine — something current systems can’t fully support yet.</p><p>Finally, there’s a resource gap. Only a small group of researchers has access to actual quantum machines. Most people rely on simulators, which don’t reflect the full potential of a quantum computer.</p><h3>A Final Challenge for the Reader</h3><p>We’ve seen how quantum computing opens up a world of new computational possibilities. Now, let’s take a moment and imagine this in a gaming context.</p><ul><li>What happens when cheat developers have access to quantum-powered tools?</li><li>What if they create a cheat software that could simulate thousands of gameplay outcomes in parallel, and could adapt in real-time?</li><li>Could quantum machine learning help mimic human behaviour better than ever before?</li></ul><p>Could this even become reality? This may be thinking too much ahead, but we need to stay ahead of the curve; the race is on! So we leave you with this challenge:</p><p><em>How would you use quantum principles to generate the next generation of cheating software?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/0*amJfgP4U25jsePN5" /></figure><h3>Bibliography</h3><p><strong>Nielsen, M. A., &amp; Chuang, I. L.</strong> (2010). <em>Quantum Computation and Quantum Information: 10th Anniversary Edition</em>. Cambridge University Press.</p><p><strong>IBM Quantum.</strong> <em>IBM Quantum Experience</em>. Retrieved from<a href="https://quantum-computing.ibm.com/"> https://quantum-computing.ibm.com</a></p><p><strong>Qiskit Textbook.</strong> <em>Grover’s Algorithm</em>. Qiskit by IBM. Retrieved from<a href="https://qiskit.org/textbook/ch-algorithms/grover.html"> https://qiskit.org/textbook/ch-algorithms/grover.html</a></p><p><strong>Preskill, J.</strong> (2018). <em>Quantum Computing in the NISQ era and beyond</em>. <em>Quantum</em>, 2, 79.<a href="https://doi.org/10.22331/q-2018-08-06-79"> https://doi.org/10.22331/q-2018-08-06-79</a></p><p><strong>Montanaro, A.</strong> (2016). <em>Quantum algorithms: an overview</em>. <em>NPJ Quantum Information</em>, 2, 15023.<a href="https://doi.org/10.1038/npjqi.2015.23"> https://doi.org/10.1038/npjqi.2015.23</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=307b18530162" width="1" height="1" alt=""><hr><p><a href="https://medium.com/anybrain/quantum-quest-an-rpg-tale-of-superposition-and-entanglement-307b18530162">Quantum Quest: An RPG Tale of Superposition and Entanglement</a> was originally published in <a href="https://medium.com/anybrain">Anybrain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>