<?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 Gyan Ganga Singh on Medium]]></title>
        <description><![CDATA[Stories by Gyan Ganga Singh on Medium]]></description>
        <link>https://medium.com/@gyanganga.singh?source=rss-dc45392bdc53------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tG0qCxF_aM8AeH9GIAHzLQ.jpeg</url>
            <title>Stories by Gyan Ganga Singh on Medium</title>
            <link>https://medium.com/@gyanganga.singh?source=rss-dc45392bdc53------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 19:44:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gyanganga.singh/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[Tech solution to run controlled experiments on Consumer groups.]]></title>
            <link>https://medium.com/airteldigital/tech-solution-to-run-controlled-experiments-on-consumer-groups-478b3d010e51?source=rss-dc45392bdc53------2</link>
            <guid isPermaLink="false">https://medium.com/p/478b3d010e51</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[product]]></category>
            <dc:creator><![CDATA[Gyan Ganga Singh]]></dc:creator>
            <pubDate>Thu, 06 Oct 2022 05:38:05 GMT</pubDate>
            <atom:updated>2022-10-06T07:29:53.466Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>A/B switch</strong></h3><p>This article is a detailed explanation on developing AB switch capability in a system. It includes:</p><ol><li>What is A/B switch</li><li>Internal working</li><li>Validating accuracy</li><li>How to integrate</li><li>Application in Airtel</li></ol><h3>What is A/B switch:</h3><p>“<strong><em>AB switch is a medium through which we can divide sample size into different control groups in order to run experiments on them and compare the outcomes</em></strong>”. By experiments we mean, whenever a new feature/functionality is being rolled out, instead of rolling it out to all the end users we want to roll it out to smaller sample size first called the control group and compare the outcome with remaining set. To achieve this we segregate the end users into two groups (A and B).</p><p>Group A: Set of users which will experience the new feature<br>Group B: Set of users which will not experience the new feature</p><p>Now it’s the task of AB switch to segregate users based on certain inputs. Let us look into next section to understand how this AB switch actually works.</p><h3>Internal Working:</h3><p>There are two main expectations from an AB switch:</p><ol><li>Its output percentage of value A/true, should be equal to the input given as abOnPercentage.</li><li>The same user should be categorised in same group again and again if we keep the abOnPercentage same.</li></ol><p>Based on above two requirements, AB switch takes two parameters as input abOnPercentage and a unique Id.</p><p><strong><em>AB Value(User) = fx(AB Percentage, Unique ID)</em></strong></p><p>Let’s understand the working with an example, Our idea is to make a boolean array, say of size 100. Suppose if the input we are given is abOnPercentage = 5%. We will make the first five values of the array as true and rest 95 values as false. Now, we will map our user, i.e. unique Id to one of the index of the array and will return the value that is present at that index. If we do this for all the users and assuming our mapping function is uniform, we have achieved what is required for an AB switch.</p><ul><li>To map the unique ID to the array index we can use certain hash functions and mod them with our array size length, so that its always between 0 to sizeOfArray-1. In our case we have simply added up all the digits of unique ID and modulus it with size of Array.</li></ul><p><strong>Arr Index(Unique ID) = SUM(Digits of Unique ID) / SIZE(Array)</strong></p><ul><li>In the actual implementation, we don’t always take the size of boolean array as 100. For e.g. if we have abOnPercentage = 5%, we take our array size as 20. Make one value of it as true and rest as false, this still makes 5% values as positive and 95% as false.</li></ul><p><strong>SIZE(Array) = 100 / GCD(abPercentage, 100 — abPercentage)</strong></p><p>Eg: <br>for abOnpercentage = 10,abOffPerecntage=100–10 = 90<br>gcd(abOnPercentage, abOffPercentage) = gcd(10,90) = 10;<br>Size of array = 100/10 = 10</p><p>One would argue, why to introduce this complexity of finding size rather than to take fixed size as 100. Answer to this lies in the next section….</p><h3>Validating Accuracy:</h3><p>To answer our previous question of why not using fixed size array and to validate the accuracy of our AB switch, we tested our AB switch on around 2.5 lakhs real world numbers(unique IDs), and the results plot are shown below:</p><ul><li>Blue line represents the actual abOnPercentage, given as input.</li><li>Grey line represents the output abOnPercentage when we took the fixed size array i.e. 100</li><li>Orange line represents the output abOnPercentage when we took the reduced size array</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdNuDcG1AWA-w09bnSK0Ow.png" /><figcaption>Comparison b/w fixedSizeArray(100) and reducedSizeArray</figcaption></figure><p>As we can see that, the resulting percentages are fluctuating in both the cases. But we observed when we kept the input abOnPercentage as multiple of 5. The variation was negligible in case of reduced size array, as shown in below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzuYIMvHzchtL0A8hlPyPg.png" /><figcaption>Comparison b/w fixedSizeArray(100) and reducedSizeArray, when abOnPercentage is kept to multiples of 5 only.</figcaption></figure><p>All in all, the accuracy and performance of AB switch is dependent on mapping function or input data(unique ID). The better one is able to map unique IDs uniformly over sizeOfArray, better would be the performance of AB switch.</p><p>That’s about theory, let’s see some code now….</p><h3><strong>How To integrate:</strong></h3><p>To integrate AB switch, we first need to add AB switch dependency on out pom.xml file, as shown below. Version can be changed to latest at the time of implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*FOcf3Gpi9eWCuWx2yVavxg.png" /><figcaption>Dependency addition in pom.xml</figcaption></figure><p>After that we need to build our project dependencies(mvn clean install), this step will download jar for AB switch from nexus. And this now can be used in project. To use this, we simply need to call the getABFlag() function of ABSwitch class and pass the required params i.e. enablePercent, uniqueId(ivUser).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-CDGS2UBanLr34bPjV6fw.png" /><figcaption>Sample usage in code</figcaption></figure><p>Thats it, we can now simply use output of that function to divide our end users accordingly. <br>To know what exact purpose it served us, let’s dive in the next section…</p><h3><strong>Application in Airtel:</strong></h3><p>Till writing this article, we have used this technique in couple of features.</p><p>One of them is inAppUpi, whenever we are going to make payment through UPI through Airtel thanks app we can select from pre-installed apps such as Google Pay, PhonePe etc. When on selecting any one of the UPI apps, we can either direct the user to the respected app(normal flow) or we can open an in screen bottom top-up(inAppUpi flow).</p><p>As the inAppUpi feature was new, we want to experiment it on first let us say 10% of users. So now, from frontend app we will be getting a boolean flag say isDeviceEligible (which will check some basic things that app is installed, acct linked etc.) If we get this flag value as true then we will consider dividing users in groups inAppUpi/Normal flow users.</p><p>Taking abOnPercentage configured, that we have taken as 10% and an unique-id(loginId), the function:</p><p><strong><em>boolean inAppUpiFlow = ABSwitch.getABFlag(enablePercent, loginId)</em></strong></p><p>will give us boolean output, depicting should we go for normal flow(false) or inAppUpi flow(true). The same flag flag we will send to frontend and based on that UPI flow can be decided.</p><p>This brings us to end of this article, keep exploring and learning !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=478b3d010e51" width="1" height="1" alt=""><hr><p><a href="https://medium.com/airteldigital/tech-solution-to-run-controlled-experiments-on-consumer-groups-478b3d010e51">Tech solution to run controlled experiments on Consumer groups.</a> was originally published in <a href="https://medium.com/airteldigital">Airtel Digital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>