<?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 Gwilym Newton on Medium]]></title>
        <description><![CDATA[Stories by Gwilym Newton on Medium]]></description>
        <link>https://medium.com/@gwilymnewton?source=rss-28b7ef2cc123------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WWVBuWD-ZVbIRtaPtqbTrQ.jpeg</url>
            <title>Stories by Gwilym Newton on Medium</title>
            <link>https://medium.com/@gwilymnewton?source=rss-28b7ef2cc123------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:14:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gwilymnewton/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[The Titanic Dataset: What mattered more wealth or gender?]]></title>
            <link>https://medium.com/@gwilymnewton/the-titanic-dataset-what-mattered-more-wealth-or-gender-b26985f8f311?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/b26985f8f311</guid>
            <category><![CDATA[titanic]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[history]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Mon, 02 Oct 2023 10:20:48 GMT</pubDate>
            <atom:updated>2023-10-02T10:20:48.288Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Titanic Dataset: What mattered more, wealth or gender?</h3><p>Using the now iconic dataset on Kaggle (<a href="https://www.kaggle.com/competitions/titanic/data">Titanic Dataset</a>), showing the survival of the passengers on board, we ask a number of questions about what changed your chances of survival.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kSByxIlV7BPInxtpUMpgA.jpeg" /></figure><p>We thought it would be interesting to explore 3 simple questions:</p><ol><li>Were women and children rescued first or the were the wealthy rescued first? Was wealth, gender or age a more significant factor in survival?</li><li>Who was more likely die, a rich man or a poor woman?</li><li>Where did the wealthiest embark on the Titanic?</li></ol><h3>Question 1) Were women and children rescued first or the were the wealthy rescued first? Was wealth, gender or age a more significant factor in survival?</h3><p>Below is a correlation chart with number 0 to 1 (or inversely 0 to -1) showing the affect one variable such as sex had on another (such as chance of survival). The darker colours indicate stronger relationships.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*uEy5qybOgOO3_1wK7k9nFw.png" /><figcaption>Correlation factor between age, sex, fare and chance of survival</figcaption></figure><p>We can see in the survived column, that sex is clearly stands out as a strong influence. The actual strength of each influence is:</p><ul><li>Fare 0.26</li><li>Sex 0.53</li><li>Age .08</li></ul><p>So from this data, we surmised that rather than the famous idea that women and children were rescued and therefore were mostly likely to survive, the order of survival was in fact, women, the rich and then the children!</p><p>It’s always good to consider multiple ways of answering the same question though, so what if we consider the average age, sex and wealth of survivors vs. non-survivors?</p><p>We took the averages and then put them in terms of the number of standard deviations from the mean. This means that if you take the average of one set of data such as age, how far away or abnormal is the variation from the standard. For example, if a data set of age had an average of 35 and a standard deviation of 5, a 70 year old man would be 7 standard deviations from the mean and therefore very unusual.</p><p>By putting this in terms of standard deviations, we get a more normalised set of numbers that can be compared, so we can compare apples and oranges or this case, fare and age. You can read this number as “How abnormal was this attribute for a survivors vs. a non-survivors”</p><ul><li>Fare .55</li><li>Sex 1.09</li><li>Age 0.16</li></ul><p>So it looks like once again we can evaluate that the order of chance of survival was women, the rich and then the children! It’s gratifying to have our results confirmed. Now lets dive deeper into whether you were more likely to survive as a poor women or a rich man…</p><h3>Question 2) So who was more likely die, a rich man or poor woman?</h3><p>We defined “rich” as a fare higher than the median fare. The mean is likely to be distorted by an uneven distribution of passengers within classes (i.e more 3rd class than 1st class passengers).</p><p>We used the Pclass (Passanger class) attribute to scrutinise our concept of “rich” and sanity check it. The median fare was around £15, which would put, by our definition, most 2nd class passengers into the “rich” category. Based on external reading, the 2nd class passengers were not what we would consider “rich”- they often had unfinished and undecorated cabins -so we will use Pclass to define “rich” instead. If a passenger had a 1st class ticket, by our definition, they are considered “rich” and those with 2nd and 3rd class tickets are considered “poor”.</p><p>To answer our question, we must simply calculate what was the average survival for a rich man (defined as male, 1st class passenger, over 18) vs a poor woman (defined as female, 2nd or 3rd Class passenger, over 18)</p><ul><li>Rich man — 37%</li><li>Poor woman — 66%</li></ul><p>This is an interesting result but if you dive deeper and calculate the survival rate for a “very poor woman” (defined as female, 3rd class passenger, over 18)</p><ul><li>Very poor woman — 42%</li></ul><p>So it looks like the order of people getting into lifeboats were poor women, very poor women and then rich men- a very interesting insight considering we suspected that rich men were more likely to survive.</p><h3>Question 3) Did the nationality of those involved impact their chance of survival?</h3><p>Like most others, I always knew the Titanic sailed from Southampton, but while embarking on this research, I discovered that it picked up passengers at other ports. Did a person’s nationality have an affect on their survival? While not necessarily 100% accurate, we will assume that if a passenger embarked from a certain country, they are a national of that country.</p><p>We began by looking at survival rates, showing a significant survival rate for the French.</p><ul><li>French (Cherbourg) 60%</li><li>Irish (Queenstown (today Cobh)) 28%</li><li>English (Southampton) 36%</li></ul><p>However, looking further into the data we know there is an uneven distribution of factors we already know influence survivability, such as wealth. Below are the average fares for each:</p><ul><li>French (Cherbourg) £62</li><li>Irish (Queenstown (today Cobh)) £12</li><li>English (Southampton) £27</li></ul><p>If we take factors we already know make for a high chance of survival — such as the set of 1st class women over 18- then the chances seem much more even.</p><ul><li>French (Cherbourg) 97%</li><li>Irish (Queenstown (today Cobh)) 100%</li><li>English( Southampton) 97%</li></ul><p>Though the results seem less clear when we invert our search by looking at the set of 3rd class boys under 18.</p><ul><li>French (Cherbourg) 40%</li><li>Irish (Queenstown (today Cobh)) 0%</li><li>English( Southampton) 23%</li></ul><p>I think it is fair to say in the end, no clear correlation can be found between a person’s nationality as an independent variable of wealth and age and that of their chance of survival.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b26985f8f311" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum Computing, Zero to Hero: Part Four — The Qubit & The Bloch Sphere]]></title>
            <link>https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-four-the-qubit-the-bloch-sphere-5200a6e473af?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/5200a6e473af</guid>
            <category><![CDATA[emerging-technology]]></category>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Fri, 15 Nov 2019 08:50:49 GMT</pubDate>
            <atom:updated>2019-11-15T08:50:49.509Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quantum Computing, Zero to Hero: Part Four — The Qubit &amp; The Bloch Sphere</h3><p>A guide to get you from foundation maths and physics to writing a quantum algorithm, and understanding everything in between.</p><p>The Series <br><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-one-the-physics-4d5ee785146b">Part 1</a><br><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-two-computational-models-f9288be28c9">Part 2</a><br><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-three-maths-1428738328ab">Part 3</a></p><p>Okay, I know you’re excited to learn something about quantum computing, having read three parts of a series already. First, we have to get something sorted out: the Oxford English dictionary says it’s spelt qubit. So that is how we will be spelling it. Not Qbit, not cuebit.</p><p>In this part we are finally going to get around to talking about some quantum computing. Namely, we are going to talk about what a qubit is in a physical and mathematical sense. A qubit is the smallest unit of quantum computing: a single quantum bit.</p><p>Just like a classical computer stores information as a bit, an electrical on/off or one/zero, the quantum computer stores everything as a quantum qubit. This is what makes the quantum computer quantum. The two key aspects of a quantum bit drive all the power of a quantum computer:</p><ol><li>A qubit can be in a superposition of one and zero</li><li>Multiple qubits can become entangled with each other</li></ol><p>In the next part we will build on this, and look at our first quantum gates, which will allow for very basic quantum computing. First, let us look at a single qubit on its own, how we form them in the physical world, and how we describe them mathematically.</p><h3>Physical qubits</h3><p>So what really is a qubit? How do I build one?</p><p>Well, any two-level quantum-mechanical system — i.e. any system that can exist in two quantum states at the same time — can be used as a qubit. Some quantum systems can exist in more than two states, and these can be used as well as long as they have a base/ground state, by which we mean a state to which they want to fall back to naturally.</p><p>Some natural candidates for these states are photons and electrons. For a full list read here.</p><p><a href="https://en.wikipedia.org/wiki/Qubit#Physical_implementations">Physical_implementations</a></p><p>Below we will try and explain a couple of the more intuitive examples, although it’s worth noting that in real life more complex systems tend to be used. Here at IBM we tend to use t<a href="https://en.wikipedia.org/wiki/Transmon">ransmon</a>s</p><h3>Example one — Photon Polarisation</h3><p>A simple example for a photon would be its polarisation, which “for our purposes” can be thought of as the light wave going up and down (vertical polarisation) or side to side (horizontal polarisation).</p><p><a href="https://www.youtube.com/watch?v=HH58VmUbOKM">Further reading</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*P83zk6TrLkttkvWd" /></figure><p>In this diagram you can see the red line representing the electric part of the electromagnetic wave (light), and it’s vertically polarised. We could use this as a quantum ONE, and if we changed it to be horizontally polarised then we could use that as a quantum ZERO. Most importantly though, polarisation can exist in superposition. It can be in a superposition of vertical and horizontal polarisation at the same time. This means our bit is a ONE and ZERO at the same time, and here we can start to see a glimmer of the power of quantum computing.</p><p><a href="https://www.youtube.com/watch?v=MzRCDLre1b4">Further Reading</a></p><h3>Example two — Electron Spin</h3><p>Analogous to the polarisation of a photon is the spin of an electron. You might remember spin from part one of this series, where we discussed the Stern-Gerlach experiment and the relation between spin and magnetism. While a photon carries two polarisations at right-angles to each other — horizontal and vertical — an electron has three axes of spin. Along any particular axis we could choose, a measurement can yield a value of either -½ or +½, corresponding to the electron being in the spin down or spin up state, respectively. We can pick any arbitrary direction as the axis we’d like to measure and then identify its spin down and spin up states with the |0&gt; and |1&gt; qubit states (see diagram). As in the case of photon polarisation, the electron can exist in any superposition of these two states, meaning that it has a certain probability of returning either -½ or +½ on measurement of its spin. It exists in an “undecided” state until that measurement is made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*215J8HVnfpqZZucN" /></figure><h3>Mathematical/Computational Model</h3><p>The model of a qubit on paper can be a little unintuitive at first (I know, it’s all unintuitive, welcome to quantum), but I will do my best to walk you through it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/50/0*tgAohcMMauy7pxwJ" /></figure><p>We represent it quite simply in its most basic form as a vector, with 𝛂 being the “amount” of ZERO of |0&gt; we have, and 𝜷 being the amount of ONE of |1&gt; we have. The issue is that due to the nature of a qubit, we are always using something that can be in superposition, and thus the amount of something we can have is a complex number. If you remember from the last part those are numbers that are partly imaginary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L6JqO2YMU7tzffBT" /></figure><p>You will notice that is a 2D diagram, therefore we would need two parts of a number to write it down. 4+2i for example would be 4 parts real, and 2 parts imaginary. We could also say this number has two degrees of freedom; if we put it on a chart it could slide up and down the real numbers from infinity to negative infinity, but also it could slide up and down imaginary numbers of imaginary infinity to negative imaginary infinity.</p><p>The problem we face is we now have two numbers 𝛂, and 𝜷, both of which give us two degrees of freedom, which in total is four degrees of freedom. We could almost say we had a four dimensional number, which as I am sure you are now thinking is a bit much, and maybe you would like to learn knitting instead of quantum computing.</p><p>But I have good news. You are going to be saved by an equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/0*joi57-Lf5ggemuBa" /></figure><p>This equation says “something must happen in the end”, i.e. the chance of it being a ONE and the chance of it being a ZERO must in the end add up to one, no matter what imaginary parts they have. This ties the numbers to each other, reducing the freedom they have to move around; in fact, it takes our four degrees of freedom down to three. So we could say we have a three dimensional number. Excellent! We live in a 3D world, so we might even be able to draw this number…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*Hrx_AScQFiaIv_i3" /></figure><p>Enter the Bloch Sphere. There are fans of the bloch sphere, as well as many who consider it a distraction from what’s really happening. My advice on this is that it’s a tool, an abstract visualization that can help you grasp what’s happening. As we have taken a 4DoF number and squashed it into 3DoF it is a lie, but a useful lie.</p><p>Let’s have a go at explaining what this diagram is showing. We are going to do this as if our qubit is a photon, and we are using the polarisation as our “information support”. We will say that vertical polarisation is our ZERO state and will use the |↑&gt; ket, and horizontal polarisation is our ONE state and will use the |→&gt; ket. So we might put them on a Bloch Sphere like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*Vs3yXUhm4AHeeI8e" /></figure><p>Okay, but why does it need to be a sphere? If we are only talking about up and down, it could just be a line. Well we can have a superposition of polarisation diagonal |↗&gt; and inverse diagonal |↙&gt; like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*47K8B4ZWX1HBjjFt" /></figure><p>Okay, now we have a superposition of polarisation, and we still have one more dimension to use. Your really don’t need to understand this, but there is a second type of way electromagnetic waves can get into superposition: we can change its phase (further reading above if you want to understand what this is). So we can also have a superposition of phase, which results in clockwise polarisation |⟳&gt; and anticlockwise polarisation |⟲&gt; like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZwUkp3tD_Y0c2zru" /></figure><p>Now you can see how each of the axes within the sphere work. Remember that we were only using polarisation as an example. While we used the blue Z axis to represent the ground |0&gt; and high |1&gt; states of polarisation |↑&gt; and |→&gt; respectively, they could have been used to represent other possible physical qubits. For example, the ground and high states could have been the spin states of an electron.</p><p>We just need to make one last visit to the first diagram you saw.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*GHTm3VBzPgZdpNx9" /></figure><p>You will notice the |ψ&gt; symbol. We use this to denote the state of the qubit. You can see in the above diagram in this case it’s not pointing along any one axis. This is because there is no reason a qubit can’t be in a superposition of |0&gt; |1&gt; in multiple ways at the same time; i.e. if we went back to polarisation it could be in a diagonal superposition (|↗&gt; or |↙&gt;) and/or in a phase superposition (|⟳&gt; or |⟲&gt;).</p><p>One way to write this is as two angles within the sphere:</p><ul><li>Θ being the rotation around the x axis (for polarisation this would be the factor of diagonal superposition, how much, and which way?)</li><li>Φ being the rotation around the z axis (for polarisation this would be the factor of phase superposition, how much, and which way?)</li></ul><p>We can bring this all back to an equation converting between a line on the bloch sphere and the vector state of a qubit. If you have a vector format with the |0&gt; and |1&gt; factors, you could draw a bloch sphere, and vice versa.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2JfMLnBPFasRXr5j" /></figure><p>There is no reason you should need to use that equation. In future when we write down the state of a qubit, we will nearly always use a ket like |0&gt; and |1&gt; to represent its state, and for superpositions we will likely just write it as a vector.</p><p>Sometimes we may show the qubit as a bloch sphere to help your intuition about what’s happening, and it’s good for you to understand the relation between the two.</p><p>So that’s it; we have lots of physical ways to represent a qubit. They have a ground |0&gt; state, and a high |1&gt; state, and ways to be in superposition between the two, and you have learned (we hope) to read the vectors and understand what kind of superposition they are in.</p><p>In our next article we will look at single qubit gates. What if I have a |0&gt; and want to make it a |1&gt;, and what if I want my qubit in a superposition? We will show you how it’s done!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5200a6e473af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum Computing, Zero to Hero: Part Three — Maths]]></title>
            <link>https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-three-maths-1428738328ab?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/1428738328ab</guid>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[algebra]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Fri, 15 Nov 2019 08:43:20 GMT</pubDate>
            <atom:updated>2019-11-15T08:52:14.811Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quantum Computing, Zero to Hero: Part Three — Maths</h3><p>A guide to get you from foundation maths and physics to writing a quantum algorithm, and understanding everything in between.</p><p>The Series<br><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-one-the-physics-4d5ee785146b">Part 1</a><br><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-two-computational-models-f9288be28c9">Part 2</a></p><p>Bad news everybody; we are going to have to learn some maths. The good news is that I am going to try to teach you as little as possible, without proving anything (sorry mathematicians). We are just going to grab the maths tools we are going to need for quantum computing and leave everything else behind. So you will see a lot of “for our purposes”, and if you know better please forgive me!</p><h3>Vectors</h3><p>Vectors are little stacks of numbers. Formally, a vector is defined as “an element of a vector space”. However, for our purposes it’s a column of numbers, where the order of the numbers is important. You will see vectors written like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/0*wHIs87jDFRlkuh0G" /></figure><p>In the case above we are using the vector to represent the measurements of a box. We could have additional vectors to represent the position, rotation and scale of the box. If we had a 2D rectangle we could have used a vector that was 2 “high”; this is its size. We can represent abstract things as vectors as well. Colour, for example, can be represented as Red/Green/Blue/Alpha, so we could write it as a vector of size four.</p><p>It’s also important to note the numbers are not independent; they are representing something. We do have a word for a group of numbers in which the order between them is not important. This is a “set”, but you won’t need to know that for our work.</p><h3>Matrix</h3><p>So, we have already introduced you to a column of numbers. What about a square? That’s all a matrix is; a collection of numbers (although again, the position and order are important).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/0*a2ab2QAUvCmE2O8W" /></figure><p>So again, let’s bring it back to something a bit more real. Let’s say we have a picture of a triangle (carefully drawn by my good self):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*wbiPDab1mOVe7Srb" /></figure><p>We could represent that as a matrix by dividing it up as a grid like so (more lines would have been better, but we the authors are lazy):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*omnKxkfc1ACojDTn" /></figure><p>We can then convert this grid into a grid of numbers showing how much “fill” there in in each square. A grid of numbers is basically a matrix. Below is a 4X4 matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*5xJi1ATzPjUFYgyz" /></figure><p>We could — and forgive me for not writing it all out — record all colour “channels” in our matrix as well, showing not only how much to shade each box, but what colors. Below we can create a 4x4x2 Matrix, where we have a blue channel as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4C783vpjZ-NHzZ8B" /></figure><p>So, to quickly recap: vectors are columns of numbers, while a matrix is a grid of numbers.</p><h3>Matrix Multiplication / Dot Product</h3><p>This is going to be one of the most important functions for us. I know we have not hit a lot of “real” quantum computing yet. It’s worth letting you know that quantum information is represented as Q-bits and we change Q-bits by passing them though Quantum Gates.</p><p>When you do this on paper, you are just doing matrix maths where the vector is the Qbit, and the Matrix is a Quantum Gate.</p><p>We refer to the type of matrix multiplication we are going to do here as a “dot product”.</p><p>The first example is easy: we’re just multiplying a matrix by a single number (a scalar).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*7PoW0TjJFLQieaAo" /></figure><p>However, if we want to multiply a matrix by another matrix we will get a new matrix.</p><p>If a Matrix has <em>m</em> number of rows and <em>n</em> number of columns, we would say it’s an (m x n) matrix.</p><p>So let’s multiply together the two matrices A(m x n) and B(n x p). When we do this, we would form a new matrix: C(m x p). Note that the new matrix size is equal to the number of rows of the first matrix and the number of columns of the second. Then the rule for each given element of the matrix C is the element at position x,y equals the sum of the individual elements in the xth row of matrix A multiplied by the individual elements in the yth column of matrix B. Let’s see this in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DLfF6DFwlQx23W21" /></figure><p>Now let’s do this with a vector. It might seem strange that I left this until after the matrix, but hopefully you can guess that a vector can just be treated as a special case of a matrix: a matrix with a single column (i.e. a vector of size v is also a matrix of size (v x 1)). So if we multiply vector V of size v by a matrix A(v x n) we get a net matrix: C(v x n).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZajDgBcbloryLSHa" /></figure><h3>Tensors</h3><p>You might have heard of tensors from things like Tensorflow. “For our purposes” we can consider them as a special case of vectors and matrices. All the vectors you encounter after this article will be tensors, so you don’t need to know the difference really, but here are a couple of definitions anyway.</p><p>1) A tensor is anything that obeys the rules of ensors (helpful…)<br>2) A Tensor is constant under a change of coordinates</p><p>Let me explain number two for you a second. Imagine we shot an arrow from a bow, towards an apple, and paused to watch it mid-flight.</p><p>We could describe many of its attributes, like its position and which way it is pointing. For these attributes to make sense, we would need a zero — or reference — point to measure from. For our example let’s say the bowman who fired it is our zero point. If something is at his exact location, it’s at zero.</p><p>We could then describe the arrow’s position and the direction it’s pointing in terms of where the bowman is standing; let’s say “ten meters away”, and “away from me”.</p><p>Now if we described it from the apple’s point of view (a “change of coordinates”) we might say “five meters away” and “towards me”.</p><p>When we changed our point of view, we changed how we described it, but the arrow was still in the same position, pointing the same way. Hence “constant under a change of coordinates”.</p><p>If you have the time you can learn all the ins and outs of them here <br>[Vectors for Beginners — <a href="https://www.youtube.com/playlist?list=PLJHszsWbB6hrkmmq57lX8BV-o-YIOFsiG">https://www.youtube.com/playlist?list=PLJHszsWbB6hrkmmq57lX8BV-o-YIOFsiG</a>]</p><h3>Covectors</h3><p>Remember vectors? When we had a column of numbers? Well now we have covectors, which are a row of numbers. Like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/0*YAXKzQ6UG1gQV5AC" /></figure><p>(Note the lack of a T, this is not a vector that’s been laid on its side (or “Transposed”), it’s a row vector).</p><p>Covectors act as functions or operations on vectors. You can think of a function as a black box that takes some input and transforms it to some output. You feed something in one side and get something out the other. When you multiply a covector by a vector you get a scalar output (scalar being the fancy word for just one number).</p><p>So if we have a covector, C, and a vector, V, we can generate the scalar output like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/0*HsoP36pj5C_2Ai0E" /></figure><p>Let’s try that with real numbers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*G0eK8upk_ljM98S2" /></figure><p><a href="https://www.youtube.com/watch?v=LNoQ_Q5JQMY">Further Reading</a></p><h3>Tensor Product</h3><p>Do you remember when we said “a tensor is constant under a change of coordinates” and discussed how the tensor is always relative to something? The more formal way to say this is that it’s part of a vector space. Sometimes you might need to get the product of two tensors from different vector spaces. For this we have the tensor product, denoted by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/0*OKc3rJvDKPp1wIZ8" /></figure><p>There is not really a good way to give you an intuitive understanding of what happens, or an easy, real-world example to help you relate. So simply “for our purposes”, just think of it as working like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/0*5PYFpDqdH9Hw9AU_" /></figure><p>The second matrix is applied at every position in the first matrix as if each of the elements of the first matrix were scalars. Note that the size of the resulting matrix is the multiplication of the number of elements in the row of each matrix by the number of elements in the columns of each matrix. If we were to take the tensor product of another 1x2 matrix and a 1x4 matrix, the resulting matrix size would be 1x8. The fact that tensor products scale so quickly is important in understanding the power of quantum computing, as the addition of a single qubit doubles the vector space of the quantum computer.</p><p><a href="https://www.math3ma.com/blog/the-tensor-product-demystified">Further Reading</a></p><h3>Bra-ket notation</h3><p>You will also come across this described as Dirac notation. Now that you know what vectors and covectors are, we have some useful shorthand to write them out: bra-ket.</p><p>Bras are row vectors (or covectors) and written like this: &lt;B|</p><p>Kets are vectors, and are written like this: |K&gt;</p><p>The most common ones you will see in this series are |1&gt; and |0&gt; This is the shorthand we use for a quantum one, and a quantum zero.</p><p>You see, we store the state of a quantum bit in what we call a one-hot register. This means we have a bunch of labels to represent the state of a thing (in this case a Qbit), and we put a 1 next to the state it’s in.</p><p>So our Qbit state can be stored like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*oZsY_ZwS6fOBqip8a6bYbg.png" /></figure><p>And when it’s a one, we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*54IN11BuA0pdbzaDH_QrYg.png" /></figure><p>And zero</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*IrT55yIASli0BuVrHgkikQ.png" /></figure><p>But wait, that’s just a column of numbers! That’s a vector. So yes, we can store a Quantum one as [1,0] and a Quantum zero as [0,1]. This leads us back to the shorthand, we can just write “the one is |state&gt; position” as |state&gt;, and that leads us all the way back to |1&gt; and |0&gt;</p><p>You will see more complex versions of this later, like |8&gt;, which means we have a vector full of zeroes and the 8th number in the list is a 1. Easier to write than [0,0,0,0,0,0,0,1]. Or you might see even more complex versions like |+&gt;. This is a case where “+” is the name of the state, and we are just saying have a special case and we can’t be bothered to write all the numbers for it, which are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/0*kSPgf0FfzMKSbuz4" /></figure><p>Just like we write 𝜋 instead of 3.14159… It’s just easier sometimes.</p><h3>Complex numbers</h3><p>Complex numbers are going to require a little suspension of disbelief, like when we looked at the physics of quantum computing. We just had to agree to believe some things.</p><p>First, imaginary numbers. You see, there is a tricky little equation:</p><p>f(x) = x² +1 = 0</p><p>The problem is, we have this bucket of numbers we call the “real numbers”, and none of them work as x. The function is unsolvable, which is an even bigger problem because we have something called “the fundamental theorem of algebra” which says that every equation of this type can be solved. So this leaves us feeling a bit awkward and silly. Either something as important as “the fundamental theorem of algebra” is wrong, or we better go looking for some new kinds of numbers.</p><p>And thus we found the imaginary numbers. There is a good argument that these should be called lateral numbers, but as 90% of the world still calls them imaginary numbers so shall we.</p><p>They are a set of numbers that you can think of as going off to 90°, perpendicular from the number line you learned at school.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wUxUFw28AF-2XTpn" /></figure><p>Just as when you see a “-” before a number you know its negative, if you see the “i” then you know its Imaginary. You can add, subtract, multiply with them just like many other numbers.</p><p>You might notice the title of this section is “complex” numbers not imaginary; that’s because what happens if something is part real numbers, and part imaginary numbers? Well you guessed it. Its “complex”, and you just write it as the sum of its complex and imaginary parts like so:</p><p>3+4i</p><p><a href="https://www.youtube.com/watch?v=T647CGsuOVU">Further Reading</a></p><p>Well done for reading all of that. You don’t need to memorise it; a lot of the reason we wrote it was to give you something to refer back to when you don’t understand something we are doing in the next part, where we will finally get to meet a Quantum bit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1428738328ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum Computing, Zero to Hero: Part Two — Computational Models]]></title>
            <link>https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-two-computational-models-f9288be28c9?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9288be28c9</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[ibm]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 13:12:13 GMT</pubDate>
            <atom:updated>2019-07-02T13:12:13.335Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quantum Computing, Zero to Hero: Part Two — Computational Models</h3><p>A guide to get you from foundation maths and physics, to writing a quantum algorithm and understanding everything between.</p><p>The Series</p><p>Part1</p><p><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-one-the-physics-4d5ee785146b">Quantum Computing, Zero to Hero: Part One — The Physics</a></p><p>It might be news to some of you that there are lots of different models of computation, or even that something called a “model of computation” exists to begin with.</p><p>A model of computation is a description of how memory, communication and computational units are organised so that they can compute a function.</p><p>So how we: <br>1) Remember things<br>2) Transmit things, and<br>3) Work things out</p><p>The aim is for these to work together to do something useful. It’s not something we talk about very much, because while there are lots of models of computation, one of them won — or has been winning for a long time — the Turing Machine. I am 100% sure that whatever device you are reading this on is a Turing Machine. So we have long ago just assumed that a computer = a Turing Machine.</p><p>This was valid, because they pretty much all were. The problem is, while a quantum Turing Machine is possible, it’s not how we build them. We use the Circuit Model, which as you will discover is equivalent in power. So we are going to need to lean to put a few assumptions aside.</p><h3>Turing Machines</h3><p>Named as many you would guess after its inventor the famed Alan Turing,a Turing Machine is a mathematical model of computation.</p><p>It defines an abstract machine [The Computer],</p><p>which manipulates symbols [Computation]</p><p>on a strip of tape [Memory and Communication]</p><p>according to a table of rules [Computation].</p><p>This is a very abstract definition, approaching computing from a maths point of view. But, most importantly, take any algorithm and a Turing Machine capable of simulating that algorithm’s logic can be constructed.</p><p>An “algorithm”, by the way, is computer science speak for “a list of instructions for doing something”. If you wrote down all the steps to make someone a cup of tea, along with the checks you need to make (i.e “how many spoons of sugar”), you would have an “algorithm” for making tea.</p><p>Because we can always build a Turing Machine for any algorithm, we call this “Universal Computation”. An important note to take heed of here is that while the Turing Machine can run any algorithm, we don’t always have an algorithm for everything. In fact, we are missing a few ones you might find surprising; finding the shortest route between a set of cities, for example, is really hard for computers. So computers and Turing Machines can’t do everything.</p><p>Let’s go back to the Turing Machine. It’s a machine that mostly exists on paper, but if we were to build it, the Turing Machine has three main parts:</p><ol><li><strong>The Tape:</strong> This is an infinite roll of tape. This tape can be written on, and written symbols can be erased or rewritten with different ones.</li><li><strong>The Head:</strong> This is the thing reading and writing the tape. The head can move up and down the tape and write, erase or re-write symbols.</li><li><strong>The Register</strong>: This is the memory of the machine. It holds the current state the machine is in.</li></ol><p>All a Turing machine does is read and write from a piece of tape. At any step, it can write a symbol and move left or right. But even with this limited set of actions it can do all kinds of things. In fact, it can do <strong>all</strong> the things that any programming language does; hence “Universal Computation” !</p><p>This is how the internals of your desktop computer work.</p><ol><li><strong>The Tape</strong> is the Cache/ Ram/ Hard Disk of your computer. They are all just fancy versions of a long tape of memory. Both the data you compute on, and the program that decides what to do next are stored here.</li><li><strong>The Head</strong> is the CPU. It can do all the maths required to decide which part of the “tape” to move to, and what to read and write.</li><li><strong>The Register </strong>is the register on your CPU. In practice there are normally a few of these, most notably the “program counter” that remembers where we are in a computer program.</li></ol><p>If you’ve noticed that’s a bit vague, it’s because your computer is a particular implementation of a Turing Machine known as Von Neumann Architecture. [<a href="https://en.wikipedia.org/wiki/Von_Neumann_architecture">Von Neumann Architecture</a> <a href="https://en.wikipedia.org/wiki/Von_Neumann_architecture]">]</a></p><p>[<a href="https://www.youtube.com/watch?v=dNRDvLACg5Q">Further reading</a>:]</p><h3>Circuits</h3><p>As I mentioned earlier there are many other models to the Turing Machine. Feel free to Google them, because for today we are only interested in one other type.</p><p>Next we are going to talk about circuits, as in the kind that live on a circuit board. While they are often used to implement a Turing Machine, they are a computational model of their own, and we will talk about how they interrelate later. First, we need to define a few things.</p><p>“Boolean function”: Boolean means True or False (One or Zero), and a Boolean function is a function that takes one or more Boolean values, and transforms them into one or more different Boolean values. The simplest is NOT. It turns a True into a False, and False into a True. Another example would be AND, which turns True only if both its inputs are also True. In other words:</p><p>False AND False = False<br>False AND True = False<br>True AND False = False<br>True AND True = True.</p><p>“Logic gate”: This is a physical device on a circuit board that realizes a Boolean function.. For example, let’s say we have a little box, and run two wires in, and one out. If that box only sends an electrical impulse out (True/One) when both the wires going in also have an electrical impulse, it’s a logic gate for an AND function.</p><p>So finally we can get to defining circuits. Logic circuits are straight lines that take a set number of inputs and pass them though logic gates, in order to create a set number of outputs.</p><p>There are a couple of important things to note from this.<br>1) There’s always a set number of inputs and outputs. A circuit made for a certain sized input can’t accept any others.</p><p>2) Straight lines mean no branching. The circuit can’t say IF (this is true) THEN (do this).</p><p>3) No branching means no looping. If you cant branch, you can’t decide when to leave the loop.</p><p>Despite this, a circuit is equal in power to a Turing Machine. For this, we need to accept two ideas (you can do the further reading if you need):</p><p>1) Circuits using just AND and NOT are Universal.</p><p>2) Universal Computational models are equivalent to each other [Strong Church Turing Thesis]</p><h3>Reversibly</h3><p>Reversibility is the ability to run a computation backwards(I will explain in a little while why this is so important).</p><p>It is possible to build reversible logic gates, and this is going to be very important. So let’s quickly look at a classical gate: the AND gate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/0*fBLYrhZpOw_t7m3q" /></figure><p>Looking at this, you can see we lose information when we go through the gate. If the output is a ‘False’ (Zero), we don’t know if the inputs were False/False or False/True or True/False. Because of this, we can’t reverse the process.</p><p>However, there is a family of reversible gate types, which we are going to see later in this series. In this case, you can see that instead of an AND we can use a TOFFOLI gate. It can be a little hard to understand, but when C=0, it acts as a reversible AND gate. We will go into details on individual gates later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/0*KeWyvlP9JvYe0wiz" /></figure><p>[<a href="https://en.wikipedia.org/wiki/Quantum_circuit">Further Reading</a>]</p><h3>Entanglement.</h3><p>So I promised I would get to why we need to make the gates reversible, and it all comes back to entanglement [Refresher here].</p><p>You see, entanglement is about information. The state of one particle is entangled with another, and when we make a non-reversible gate we lose that engagement.</p><p>Let’s imagine you (Alice) and your friend (Bob) are playing a (weird and boring) game.</p><p>You each have a stone with a white side, and a black side.</p><p>When you play, Bob shows his stone to Alice. If it’s white side up, Alice has to flip her stone over (for those of you paying attention, our game is a Controlled NOT gate, or a CNOT gate).</p><p>So to write it out as a table we would get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_G4wjVoQclKEttP37FEAVA.png" /></figure><p>Now, let’s put Bob’s stone in superposition [Refresher here] so its state is White/Black with a 50% change of being in either state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9jI3mArhf9JYSleLN0hog.png" /></figure><p>You can see they are now entangled. <br>If you want a quick refresher on entanglement, it’s [Refresher here], but quickly it means two things are in a superposition of states, such that by manipulating one, if affects the other.</p><p>We don’t know what side Alice’s stone is on, because it’s based on Bob’s. Until we measure Bob’s (look to see if the black or the white side is up), we can’t know what happened to Alice’s.</p><p>For instance, we could “measure” Alice’s stone. Let’s say when we measure it it’s white, and we remember it was white before we did anything. We know it hasn’t flipped, and according to the rules of the game that would only happen if Bob’s stone is black, so we now KNOW it’s black.</p><p>We could also do it the other way around. If we measured Bob’s stone and it was black, and we know Alice’s was white to begin with, then we KNOW Alice’s is now white without looking at it.</p><p>This is entanglement.</p><p>There is another thing we can do: “reversibility”. Let’s change the game up a bit, and say Alice and Bob have such terrible memories that as soon as you play each round they forget everything that happened before.</p><p>We can get rid of the “before parts” because of their terrible memories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4a0eiyMIREKIRf7vXwrTBw.png" /></figure><p>What we could work out is “Measure” of them. Let’s say we look at the stones and both Alice’s and Bob’s are white.</p><p>Okay, so according to the rules, Bob’s will have stayed the same (o his was white before), and Alice’s flips if Bob’s was white, which it was, so Alice’s must have been black.</p><p>This is reversibility, the ability to construct the past from the present, in order to run time backwards.</p><p>So, this is the “reversible” version of the game. Let’s change the rules up again, and give Bob sudden amnesia and an urge to throw rocks.</p><p>So after the game is played, he throws his rock away and forgets what side it’s on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pR3d3Lq8n9jrQhnqHeCAeg.png" /></figure><p>So, we can measure Alice’s.</p><p>We can’t measure Bob’s because he forgot, and threw it away.</p><p>As a result they can’t be entangled, because while you could measure Alice’s and work out what Bob’s was, you can’t measure Bob’s to work out what Alice’s was. <br>Also, we can’t reverse it, because we are missing part of the information. If we measured Alice’s and found it was white, we don’t know if it was flipped to white, or was always white.</p><p>Hopefully you can see from this.</p><p>Entanglement = “Preservation of Information” = Reversibility</p><p>This is why we need reversible gates, because lost entanglement is bad. We will explain why in a few more articles as it requires some maths, but you deserve a crumb of truth.</p><p>People sometimes say a Qbit (Quantum Bit) is equal to 2^n classical bits. <br>So 4 Qbits = 16 classical bits, <br>8 Qbits = 256 classical bits.</p><p>16 Qbits = 65,536 classical bits.</p><p>This performance improvement is MASSIVE, but what this really means is 16 <em>fully entangled</em> Qbits = 65,536 classical bits. The entanglement is what gives us this power, and because we lose entanglement if we lose information, we have to make quantum computing reversible.</p><h3>Complexity</h3><p>Okay, here is the last thing we are going to learn today. It’s about how complex algorithms are, and thus how we can compare them.</p><p>First, Big O. This is the way we describe the worse case of an algorithm’s performance(e also have a little O, and a Theta, but we don’t use them as worst cases are the most important the majority of the time).</p><p>So the Big-O of an algorithm says: “If you gave the worst possible input to an algorithm, this is how badly it would perform.”</p><p>So let’s think about finding data. We are going to lay it out in two ways. You are going to have a number of boxes — “n” — and one of them has your data in it.</p><p>The first way we are going to lay out the data is to put all the boxes in a row on the floor, and you can chalk a number from 0 to n in front of each. We will call this THE ARRAY.</p><p>We are going to take the same boxes, write a number from 0 to N on the top of each of them and stack them all up on top of each of them at random. We will call this THE STACK.</p><p>Now, I will tell you I want the data from box… 15.</p><p>If you went to THE ARRAY, you could just walk up to box 15 because it has a chalk number in front of it. We would say this has “Big O 1” or O(1) because it took one attempt to find the box, and no matter what number I gave you, it would always take one attempt even in the worst case.</p><p>Next, if you went to THE STACK you would have to check the top box, and if it was not box 15, you would need pop a box off the top and look at another, and then maybe another. In the worse case box 15 would be at the bottom, and you’d need to take every other box off one at a time. So the worse case is you have to move “n” boxes (the total number of boxes), so we would say this has “Big O n” or O(n).</p><p>You can clearly see that for getting to your box, THE STACK is worse than THE ARRAY, but now you can explain why. O(n) is worse than O(1). This is how we compare algorithms; you can see the Big O of more them at [Big O cheat-sheet — <a href="http://www.bigocheatsheet.com/">http://www.bigocheatsheet.com/</a>].</p><p>Okay. The next thing you need to understand is what we computer scientists mean when we say an algorithm is complete.</p><p>“A complete algorithm always gives the best answer to the problem its solving”</p><p>For example, what if we had an algorithm that stacked all the stuff in your cupboard in the least possible space? If you could prove that every time it stacked everything, it always gave the optimal answer, and there would never be a better way, we would say that algorithm is “Complete”</p><p>The last thing is just to check you know what a polynomial is. It’s just this:</p><p>…x⁴+x³+x²+x +c</p><p>It’s an equation that matches that patten.</p><p>So you’re ready now to see the biggest and most important question in the whole of computer science. Are you ready for it?</p><p>P = NP ?</p><p>A bit underwhelming, isn’t it? Let’s explain what it’s trying to say.</p><p>There are problems for which there are complete algorithms, where the complexity (Big O) is a polynomial O(xn+…+…x3+x2+x +). We call these P.</p><p>There are problems for which there are NOT complete algorithms, where the complexity (Big O) is a polynomial O(xn+…+…x3+x2+x +). We call these NP.</p><p>The question is, have we simply never found the complete algorithms for the NP problems or do they not exist?</p><p>Is NP part of P, and we just don’t know it?</p><p>P = NP?</p><p>Why did you need to know this? Well, the question is, are better quantum algorithms out there? For some problems, are there quantum algorithms with better performance (smaller Big O)?<br>Yes, actually, this is something we do know.</p><p>Are there polynomial time complete quantum algorithms to the NP problems (maybe)?</p><h3>Onward to Quantum Computing</h3><p>Lets quickly review what we learned.</p><ol><li>What a Turing Machine is, and the model of how existing computers work.</li><li>An alternative model; the circuit model of computing.</li><li>That reversible computing allows us to go backwards in time when doing computation, and return to past states.</li><li>That reversible computing is a requirement of entanglement, and engagement gives quantum computing its power.</li><li>How to compare the complexity of algorithms, and a glimpse at the idea that for some problems, quantum can be better.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9288be28c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum Computing, Zero to Hero: Part One — The Physics]]></title>
            <link>https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-one-the-physics-4d5ee785146b?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d5ee785146b</guid>
            <category><![CDATA[quantum-computer]]></category>
            <category><![CDATA[quantum-physics]]></category>
            <category><![CDATA[quantum]]></category>
            <category><![CDATA[science]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Tue, 28 May 2019 11:37:13 GMT</pubDate>
            <atom:updated>2019-07-02T13:15:58.471Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quantum Computing, Zero to Hero: Part One — The Physics</h3><h4>A guide to get you from foundation maths and physics, to writing a quantum algorithm and understanding everything between.</h4><p>Quantum physics isn’t really a difficult subject to understand, despite many famous quotes from people like Feynman:</p><p>“If you think you understand quantum mechanics, you don’t understand quantum mechanics.”</p><p>The real issue is that it is counter-intuitive; parts of the quantum world don’t act as your gut tells you they should. If you can suspend this disbelief, quantum physics is nothing but a set of rules to learn and follow.</p><p>I will do my best to explain, without long proofs, the concepts you need to understand quantum computing. If you want to dig a little deeper I will be adding [Extra Reading] tags like this.</p><h3>Superposition</h3><p>Superposition is what we talk about when we say something quantum can be “many things at the same time”.</p><p><strong>Intuition: </strong>An attribute of something is a known quantity; a bar of steel is either 1kg, or 10kg, whether it is on a scale being weighed, sitting on the ground, or being carried by a weightlifter. It was always 1kg, or 10kg, and until a physical process changes it, it always be either 1kg or 10kg.</p><p><strong>Quantum world</strong>: A quantum system exists in a superposition of states; the system is in all of its possible states at the same time, but each state has a probability amplitude (a chance) that tells you how likely you are to observe the system in that particular state when you measure it.</p><p>Let’s imagine a quantum particle. Our particle has a state that could be represented by a letter: A, B, or C. It could be in a superposition of being A, B and C all at the same time. Let’s say with a 25% chance of being A, 50% of B, and 25% of C.</p><p>Then we would measure it. Let’s imagine we have have a machine which goes “Fizz” if you put a particle in state A into it, “Buzz” for a particle in state B, and “Bang” for a particle in state C. The machine needs to find out if the particle is in state A, B or C to know what sound to make. This is “measuring” it, and once we have measured it we say the “superposition has collapsed”. The particle has made its choice, maybe an A in this case, and the machine goes “Fizz”.</p><p><strong>A couple of important notes</strong><br>There is no hidden variable inside the particle that it only lets us see when we measure it. It’s not that we had a 25% chance of putting an A particle into the machine; the particle itself never decided if it was A, B or C until the moment we asked it. <br>[Extra Reading — <a href="https://www.youtube.com/watch?v=zcqZHYo7ONs">Bell’s Theorem</a> ]</p><p>It’s worth noting that the particle is in multiple definite states at once, not in between them. Let’s say it the particle is a number, 1 or 0. If it is in a superposition of being both, then it is 1 and 0 at the same time, not half way between them: it is not “0.5”. When we finally measure it, it will only then become 1 or 0.</p><h3>Spin</h3><p>What is spin? We don’t know, and like many things we don’t understand we just popped a label on it to make ourselves feel better. The best definition I can give you is: “Something that makes quantum particles pretend they are magnets.” There are better definitions out there, but for the sake of quantum computing this will do.</p><p>The concept of spin comes from the Stern-Gerlach experiment. Particles (in the original experiment, silver particles with the chemical symbol Ag) are shot through a magnetic field onto a screen. The magnetic field is spatially varying, meaning the pull on the particles is not even. Otherwise we would expect the North/South pulls to cancel each other out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/0*d3XUkpyi9GAiUTl_" /></figure><p><strong>Intuition:</strong> <br>In the classical world, if these particles were magnetic, they would have their North and South poles aligned randomly, pointing up, down, or somewhere in between. By using a changing magnetic field, particles are pulled gradually upwards or gradually downwards depending on how their magnetic poles are aligned. If everything is behaving like classical magnets, this would form a vertical line on the screen, because we would expect:</p><ul><li>Particles with the “north side” up to go all the way up.</li><li>Particles with the “south side” up to go all the way down.</li><li>Particles on their side to go straight, because they don’t get pulled at all.</li><li>Particles at an angle to go slightly up or slightly down, based on the angle and how much they get pulled.</li></ul><p><strong>Quantum world</strong>: Nope. They all go either all the way up, or all the way down, forming two dots on the screen instead of a vertical line. One fancy way of saying this of course is that it is quantised (A or B). There is not a classical spectrum of values like letters, where a letter has to be A or B, it can’t be halfway in between.</p><p>It’s back to that pesky superposition again: particles are never “on their side,” they are in a superposition of being both up and down. “On their side” just means there was a 50/50 chance of being “north side” up or “south side” up, not having yet made a choice, but then we measured them with the Stern-Gerlach experiment and they made a choice of up or down. So the particles always go either all the way up, or all the way down.</p><p>If you were to rotate the apparatus 90 degrees so they were pulled left or right, then you would expect that the results would not change. We would get all left, or all right.</p><p>The spin collapsing into either up or down relative to the experiment is as a result of the particular particle interaction with the magnetic field where the only two possible states are up and down.</p><p>You will start to see notation like this creeping in later in the series <br>|φ&gt; = α•|↑&gt; + β • |↓&gt; <br>Which can look rather alarming, but it’s really quite easy to read once we let you in on the secret.</p><p>|φ&gt; just means “The state of the particle”</p><p>α•|↑&gt; just means “how likely is it to decide to be up, where α is the size of the chance”</p><p>β • |↓&gt; just means “how likely is it to decide to be down where β is the size of the chance”</p><p>So a particle that’s always going to be up?</p><p>|φ&gt; = 1•|↑&gt; + 0 • |↓&gt;</p><p>Or always going to be down?</p><p>|φ&gt; = 0•|↑&gt; + 1 • |↓&gt;</p><p>Fifty/fifty chance?</p><p>|φ&gt; = 1/√2•|↑&gt; + 1/√2 • |↓&gt;</p><p>(Okay, that last one is a bit more confusing, I promise we will get around to it in part three.)</p><p>[Extra Reading — <a href="https://www.youtube.com/watch?v=cd2Ua9dKEl8">What is spin</a><a href="https://www.youtube.com/watch?v=cd2Ua9dKEl8]">]</a></p><h3>Entanglement</h3><p>Entanglement is where quantum physics gets fun (and very useful for quantum computing).</p><p>This one is actually reasonably intuitive, although some of the later parts in the further reading I will add are less so.</p><p>An important rule to mention now: the laws of physics state there is conservation of certain properties, like spin. Conservation means “we can’t change the total amount in the universe”; in terms of energy this means we can’t create more or destroy any existing energy, we can only transform it. In terms of spin, it means all the UP spins must equal all the DOWN spins, there can’t be more of one than the other.</p><p>So, let’s try a thought experiment. Let’s say we create a pair of quantum particles, and they are in superposition. Each is 50/50 between being spin up and spin down. Knowing what we know about conservation of spin, if we make an up, then we also have to make a down, right?</p><p>However, they are in superposition — i.e. both up and down at the same time — so what happens if we measure the first one? Say we measure it and observe that it is spin up. What do we then know about the second particle? Well since all the ups and downs must balance, the second particle MUST be spin down.</p><p>This means we can set up particles where the probabilities of their spin are interconnected… or entangled! By adjusting the superposition of one, we change the other.</p><p>If we could tweak the first particle so that it has a 75% chance of being observed up and a 25% chance of being observed down, then the second (entangled) particle must become 25% likely to be observed up and 75% likely to be observed down. By measuring one we instantly know the state of the other.</p><p>There are couple of interesting add-ons to entanglement, which you don’t need to understand right now, but are:<br>[Extra Reading — <a href="https://www.youtube.com/watch?v=owPC60Ue0BE">No cloning Theorem</a>]</p><p>[Extra Reading — <a href="https://www.youtube.com/watch?v=DxQK1WDYI_k">Quantum Teleportation</a>]</p><h3>Onward to Quantum Computing</h3><p>Lets quickly review what we learned.</p><p>1) Superposition: The state of a particle can be many states at once, with a chance of being in each, but when measured it must choose what state it is (and was) in.</p><p>2) Spin: This is an attribute of a particle that makes it act like a magnet. It is part of the state of a particle that can be superposition, and must collapse to a single state when measured.</p><p>3) Entanglement: The superposition of a particle can become “connected” to the superposition of another, so that by manipulating the superposition of one, you are manipulating the other, and by measuring one, you have measured the other.</p><p>In the next section, I will go on to discuss what this all means for creating a quantum computer. But even now you can maybe see the possibilities. Imagine a machine that modifies bits in some unknown way, and we needed to find out what it does.</p><p>In a classical computer, we would have to put in “one” and a “zero” in to find out what it did to them. So, two attempts.</p><p>If only there was a way to put a bit in that was a one and zero at the same time?! Then we could see what would happen with only one attempt…</p><p>Part two is now available:</p><p><a href="https://medium.com/@gwilymnewton/quantum-computing-zero-to-hero-part-two-computational-models-f9288be28c9">Quantum Computing, Zero to Hero: Part Two — Computational Models</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d5ee785146b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playing with the Bloch Sphere]]></title>
            <link>https://medium.com/@gwilymnewton/playing-with-the-bloch-sphere-6e253f3f855f?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e253f3f855f</guid>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[gamification]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[unity3d]]></category>
            <category><![CDATA[qiskit]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Fri, 03 May 2019 15:09:25 GMT</pubDate>
            <atom:updated>2019-05-03T15:09:25.601Z</atom:updated>
            <content:encoded><![CDATA[<p>How we made a game of learning Qubits.</p><p>In this article we will briefly show the tool we built while learning quantum computing; alas, this article is not about teaching these concepts. We will be covering these in a series of articles soon.</p><p>At the start of our journey we were learning about qubits, and basic operations on them. A qubit (or Qbit) is a quantum bit. While a normal bit is represented as a simple one or zero, a Qbit is the state of a quantum particle, and thus has superposition. This means it can inhabit the space between one and zero. This complex state can be represented in lots of different ways.</p><p>For example, a simple base “0” can be shown as as the sum of “Ks”. This says: “The state is made of one lot of zero, and no ones.”</p><p>|φ&gt; = 1•|0&gt; + 0 • |1&gt;</p><p>Here it is as a single ket shorthand. This says: “It’s all made of the zero state.”</p><p>|0&gt;</p><p>Here it is as a vector. The first row is the amount of zero we have (one) and the second is the amount of one we have (zero).</p><p>|1|<br>|0|</p><p>Here it is as a Bloch Sphere. This is probably the most common visualisation we use. The amount of of the zero state and the one state we have are both complex numbers. They have real and imaginary parts. Two numbers with two degrees of freedom means 4 degrees of freedom (or a 4D number if you will). However, because the squares of these numbers must add up to one, we lose a degree of freedom, and can cram this 4D number into “3D” space and draw it as points on the surface of a sphere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8__sZpRz1C212n_1" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*n0JGFiHO7MiVieYL" /></figure><p>The more we dove into this the harder and less intuitive it became for computer scientists like us. How, for example, do you get from the |φ&gt; = α•|0&gt; + β• |1&gt; representation to working out the angles θ and φ in the bloch sphere?</p><p>I won’t leave you hanging, because we had to work it out ourselves after not finding it anywhere we searched:</p><p>Θ = 2cos-1(α)</p><p>and</p><p>φ = log(β/sin(Θ/2))/i</p><p>Then it comes time for Quantum Gates, which are linear maps that you apply to a Qbit. For example, the Pauli Gates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/0*-xEMhepb0S5AU7UI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/0*Qk8hpSqcJz_iv6Id" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/0*vHfQy1RhD4PVdu5n" /></figure><p>The way these gates are applied is to multiply them by the Qbits’ vector. They are described at 180-degree rotations around the X,Y,Z axis of the Bloch sphere. Except that’s not exactly true.</p><p>You see, the Bloch sphere is a really useful lie. It’s a way of cramming a number with degrees of freedom into 3D space, which means it does strange things.</p><p>Let’s take the X,Y gates for example. If they were true 180-degree rotations as you were expecting, then |0&gt; (shorthand for zero) would flip |1&gt; (shorthand for one) and vice versa. The X gate does this; well done X gate. The Y gate, however, flips |0&gt; to |i&gt; (imaginary one).</p><p>This is all really confusing, and we will be writing some articles about it in the near future to explain it. Right now however, we want show you the tool we built to help us understand it all.</p><p>This was built in Unity3D at IBM’s Emerging Tech Labs. It represents the Qbit internally as two complex numbers, and then translates this into 3D animations so you can visualize what on earth is going on while at the same time viewing the maths though the UI.</p><p>If you want to download and play with it, the public github is here:</p><p><a href="https://github.com/GwilymNewton/BlochSphereExplorer-">GwilymNewton/BlochSphereExplorer-</a></p><p>We also have a video of it action:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0BYWoxM1kVU%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0BYWoxM1kVU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0BYWoxM1kVU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/861619ffb41ccdd10804a0d2b1a51a5b/href">https://medium.com/media/861619ffb41ccdd10804a0d2b1a51a5b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e253f3f855f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Alice in Wonderland with the IBM Virtual Voice Creator]]></title>
            <link>https://medium.com/@gwilymnewton/creating-alice-in-wonderland-with-the-ibm-virtual-voice-creator-97f842180af2?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/97f842180af2</guid>
            <category><![CDATA[text-to-speech]]></category>
            <category><![CDATA[alice-in-wonderland]]></category>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[voices]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 14:03:00 GMT</pubDate>
            <atom:updated>2019-01-08T14:03:00.306Z</atom:updated>
            <content:encoded><![CDATA[<p>I was lucky enough this month to get access to one of IBM latest and most exciting experiments in Text-to-Speech, the ability to create voice personas. This allows us to do a couple of exciting things, first to create unique one off virtual voices for our speech, and then to control those voices depending speech being spoken allowing us to better express emotion.</p><p>I wanted to be able to show this off to my colleagues and clients so I went digging for a suitable script to use, and Volla! I found Alice in Wonderland, and thought the first few paragraphs from “The Mad Hatters Tea Party” would suit nicely.</p><h3>Voices</h3><p>The first job was to create some voices. Here is the one we built for Alice</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFpaoUCjWrBjo58VPjDWyg.png" /></figure><p>You can see we made her speak slowly, not very tense, and crisp. This gave her the dreamy but well educated sound the feels like “Alice”, you can listen to our first attempt below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F555837627%26show_artwork%3Dtrue&amp;url=https%3A%2F%2Fsoundcloud.com%2Fuser-589967674%2Falice-imposible-breakfast&amp;image=http%3A%2F%2Fa1.sndcdn.com%2Fimages%2Ffb_placeholder.png%3F1546852553&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddb031759e20764d31abe74e40ee4f9c/href">https://medium.com/media/ddb031759e20764d31abe74e40ee4f9c/href</a></iframe><h3>Script</h3><p>Next we needed to load in the script, the suite of tools allows us to upload the text, and tag it with the voices we are planning to use. You can see part of what that looks like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9M4IEJhDjDMeY5F0dvoSsg.png" /></figure><h3>Emotion</h3><p>Voices are not made equal, I have my voice, but I also have my sad voice, and my angry voice. Our tool knows this, and allows you to change particular words or phrase to have different emphasis without needing to create entire new voices.</p><p>See if you can here the difference here is our original calm Alice</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F555846552%26show_artwork%3Dtrue&amp;url=https%3A%2F%2Fsoundcloud.com%2Fuser-589967674%2Falice-plenty-of-room-calm&amp;image=http%3A%2F%2Fa1.sndcdn.com%2Fimages%2Ffb_placeholder.png%3F1546954660&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/de80a2ef17a17785647af3c27831ece2/href">https://medium.com/media/de80a2ef17a17785647af3c27831ece2/href</a></iframe><p>She sounds a bit too calm and reasonable, but we don’t want to change the whole voice, so we can just change how these particular words are pronounced within the script tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*j5a50eOEqg9Zwg77uKdCsQ.png" /></figure><p>The blue bar shows an increase in excitement for the voice, and the bold “Plenty” shows the word should have more emphasis. Lets listen again</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F555846597%26show_artwork%3Dtrue&amp;url=https%3A%2F%2Fsoundcloud.com%2Fuser-589967674%2Falice-plenty-of-room-excited&amp;image=http%3A%2F%2Fa1.sndcdn.com%2Fimages%2Ffb_placeholder.png%3F1546954660&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ba797fe1ff048bb9de060f1aa997089/href">https://medium.com/media/7ba797fe1ff048bb9de060f1aa997089/href</a></iframe><p>That sounds much better, far more indignant.</p><h3>Results</h3><p>Below is the results of a half a days fiddling around with voices, I am sure with some more time and effort I could get it sounding much better, but I think the results we got even in a short time are amazing.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhJyzkS74DFc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhJyzkS74DFc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhJyzkS74DFc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e23fb075bd41156c8abeea714bc9b3eb/href">https://medium.com/media/e23fb075bd41156c8abeea714bc9b3eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97f842180af2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding Hidden Cells Phones in Prisons]]></title>
            <link>https://medium.com/@gwilymnewton/finding-hidden-cells-phones-in-prisons-16421352e039?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/16421352e039</guid>
            <category><![CDATA[node-red]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[software-defined-radio]]></category>
            <category><![CDATA[hackathons]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Fri, 21 Dec 2018 16:46:49 GMT</pubDate>
            <atom:updated>2018-12-21T16:46:49.562Z</atom:updated>
            <content:encoded><![CDATA[<p>Myself and some colleagues from <a href="https://www.emerging-technology.co.uk/">IBM’s Emerging Technology</a> attempted a two-day project just before Christmas this year, because we thought we might have the tech to tackle a big problem: cell phones in prisons, we know prisoners have them, but they are rarely ever tracked down. This is something the UK government is currently planning to spend £7 million on. We thought we could do it for fifty quid.</p><p><strong>Getting Started</strong></p><p>Cell phones broadcast over radio frequencies much like traditional radios, and for our project we decided to home in on the two major UK telephone networks: Vodaphone and Telefonica (O2/GiffGaff).</p><p>Our first big win was to get a copy of Vodafone’s Licence agreement with Ofcom, he UK radio spectrum standards agency.</p><p><a href="https://www.ofcom.org.uk/__data/assets/pdf_file/0025/83572/Cellular-LICENCE-Vodafone-0249664-14-12-16w.pdf">https://www.ofcom.org.uk/__data/assets/pdf_file/0025/83572/Cellular-LICENCE-Vodafone-0249664-14-12-16w.pdf</a></p><p>The biggest nugget here was finding the frequencies on which Vodafone operates The spectrum is purchased in 5Mhz chunks, and here are the ones the company uses for their PWN.</p><p>Downlink frequencies:</p><ul><li>925.1–930.1 MHz</li><li>935.1–939.7 MHz</li><li>947.3–955.1 MHz</li><li>1810.9–1816.7 MHz</li></ul><p>Uplink frequencies:</p><ul><li>880.1–885.1 MHz</li><li>890.1–894.7 MHz</li><li>902.3–910.1 MHz</li><li>1715.9–1721.7 MHz</li></ul><p>Time to get some hardware. Here’s what we used, and how much it cost:</p><ul><li>Raspberry Pi, £20</li><li>SDR(Software Defined Radio), £30</li><li>And that’s it!</li></ul><p>And have a little peek around the spectrum:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*whSaM8yRgXKRd0v6" /></figure><p>As you can see from the image above, when we looked in the lower parts of the Vodaphone spectrum, we could see a big spike in the RSS (Relative Signal Strength) whenever we made a call out.</p><p>The next thing to do was to see if we could get more exact information. We won’t bother you with the day we spent fiddling with gain, frequency and granularity setting, trying to dial in on what was happening. Instead, we’ll just present you with our best chart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5z0vBU3jmXeFlvuJ" /></figure><p>This gave us the RSS for both sets of traffic every time a cell phone call was made. The downlink ended up being very useful, as the cell tower signal was a lot stronger and therefore easier for us to pick up and work with.</p><p><strong>Bringing in AI</strong></p><p>Now we could see the signals from the mobile phone (although not read them, as the GSM protocol that cell phones use is encrypted), we could watch how they changed as I moved around the room.</p><p>We divided our space into seven chunks: our big room was split into six pieces, and the nearby kitchen made up the seventh. Then I made a lot of phone calls. And I really do mean A LOT. Altogether, my team and I cranked up over 150 missed calls over a period of two days. But this meant we had training data, so we could show an AI things like “this is what the signal looks like by the sofa”, and “here is what it looks like by the projector”.</p><p>For example, when there were no phones active we saw RSS values of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNo4e6Kkr14m0ghcSrjVZw.png" /></figure><p>(Base was our name for “No call active ”)</p><p>And when I was in the kitchen we would see values of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09TO_z4R0g-N8WkYsVQNuQ.png" /></figure><p>(We designated the kitchen Cell six)</p><p>See the difference? Well we trained a AI system, using Watson Machine Learning, to be an expert at telling the difference.</p><p>With only six “wandering around the room’s” worth of data, we managed to hit around 75% accuracy on our models. In the real world we would push this up, with more and better sensors, and of course way more data. BIG DATA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/0*5Tq3_WOsEPdTBTnU" /></figure><p><strong>Getting a better Baseline.</strong></p><p>The problem with our working environment was that it was a hackathon with tons of mobile phones, people, fitbits and little electronic bits and bobs everywhere. To solve this, it was time to go underground… to our Anechoic Chamber, a room where almost no electromagnetic radiation can enter or leave.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/0*aZoBwim8bqK31kDI" /></figure><p>This allowed us to get much better “base signals”, and we are looking to add this into our machine learning system soon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mz9g3n5pE5jGTEWXeeIgfQ.png" /></figure><p><strong>The Prototype</strong></p><p>All of this work allowed us to build a prototype system for detecting where a cell phone was in the conference room in which we were working.</p><p>This was all build in <a href="https://nodered.org/">Node-red</a>, a visual programming language that came out of IBM Emerging Tech over the last few years.</p><p>First we had a basic debug interface, which allowed us to see the RSS values we were interested in at any given moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x9yP4ne5jhbo4dxC" /></figure><p>Next we made a basic map of our testing area, with each square showing one of the “cells” of the room. It would light up red if a phone call happened, and show our confidence we were correct as a percentage.</p><p>You can see in our first screen shot here, it lights up when I make a phone call in the top left of the room, were our team was working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jcrQh26wzlccpuqo" /></figure><p>Then as I walked further down the room towards the kitchen, it can see that movement and show it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pE_a-FmPNvyiUf1Q" /></figure><p>The confidence scores are low, but this is to be expected; we had only made six phone calls from each location to train the machine learning system. Furthermore, this is one of the fastest and easiest wins to improve the system: just teach it more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16421352e039" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building the IBM Emotive Droid]]></title>
            <link>https://medium.com/@gwilymnewton/building-the-ibm-emotive-droid-55b2dec26cd8?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/55b2dec26cd8</guid>
            <category><![CDATA[ibm-watson]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[emotional-intelligence]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Tue, 18 Dec 2018 11:33:11 GMT</pubDate>
            <atom:updated>2018-12-18T11:33:11.788Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Animating emotion.</strong></p><p>This is a project to show of the use of affective computing (Emotional AI) in the Watson suite, which is IBM’s collection of cloud-based AI API’s. We hooked this into The Waston SDK for Unity, which allowed us to use this as a 3D Environment.</p><p>The goal here was simple: to create an animated object that reacts to a user’s voice, and understands the emotion it is conveying.</p><p>First we needed to use <a href="https://www.ibm.com/watson/services/speech-to-text/">Watson Speech to Text</a> to detect when somebody is talking, and then what is being said We also used this to pick up on certain keywords, in order to trigger other actions like clearing and resetting the animation.</p><p>Once we had the text, we could then run it though <a href="https://www.ibm.com/watson/services/tone-analyzer/">Watson Tone Analyser</a> .This allowed us to pick up the emotional content of the speech. We used the five-factor model from modern psychology, which assumes there are five core emotions: Joy, Sadness, Fear, disgust and anger. Any other feelings are seen as a mixture of one or more of these core five.</p><p>Importantly, we can also understand how confident we are in this emotional content, Watson Tone Analyser produces a confidence score for each emotion, everytime we analyse text. If the system is confident, and the user expresses enough of a particular emotion, the Droid in our animation scene will then react to it.</p><p><strong>Modeling Emotion</strong></p><p>To model emotion inside the project, we created a concept of emotional buildup, alongside several thresholds.</p><p>As you talk, and through Watson Tone Analyser we understand you are expressing a certain emotion, we can then add to the emotional build of that feeling This also triggers decay in other emotions, and if an emotional buildup hits one of our thresholds then a new emotional state will be reached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*0Ovv8KvolB4fSg2dod-fXg.png" /></figure><p>In other words, if the Droid is sad and you say happy things, it becomes happier and the “sadness” emotion begins to decay. If you say enough happy things, it will hit one of the thresholds and its emotional state will change from being sad to being happy.</p><p>Here are some excerpts from the code, showing how it was done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e81c72ce9586e3ffd451d977ce3a5f91/href">https://medium.com/media/e81c72ce9586e3ffd451d977ce3a5f91/href</a></iframe><p><strong>Results</strong></p><p>Here you can see my amazing colleague <a href="https://medium.com/u/5330164cb3c6">Amara Graham (Keller)</a> giving the code a whirl. We picked a little Droid for the project, and gave it a very simple (and looping) animation for each emotion. Watch the video to see it in action, or download the code and try it yourself!</p><p><a href="https://github.com/GwilymNewton/IBM-Emotive-Droid-Demo">GwilymNewton/IBM-Emotive-Droid-Demo</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDxuOkpmh61U%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDxuOkpmh61U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDxuOkpmh61U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c3ecba35b9c08bf624bab9ee9f890ab/href">https://medium.com/media/7c3ecba35b9c08bf624bab9ee9f890ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55b2dec26cd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a Chess Game with IBM Watson, and Unity]]></title>
            <link>https://medium.com/@gwilymnewton/writing-a-chess-game-with-ibm-watson-and-unity-58aa00f3d30f?source=rss-28b7ef2cc123------2</link>
            <guid isPermaLink="false">https://medium.com/p/58aa00f3d30f</guid>
            <category><![CDATA[ibm-watson]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[emerging-technology]]></category>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Gwilym Newton]]></dc:creator>
            <pubDate>Thu, 13 Dec 2018 15:34:12 GMT</pubDate>
            <atom:updated>2018-12-13T15:34:12.196Z</atom:updated>
            <content:encoded><![CDATA[<p>With the release of the Watson Unity SDK in 2018, myself and <a href="https://medium.com/u/5330164cb3c6">Amara Graham (Keller)</a> set out to build a chess game that could be completely voice controlled.</p><p>In order to tackle this, we had three major tasks ahead of us, each of which had a clear solution.</p><p>First of all, we would need our application to be capable of understanding speech, as well as being able to process it. Enter <a href="https://www.ibm.com/watson/services/speech-to-text/">Watson Speech to Text</a>.</p><p>Next, we would need to create a conversational AI that could follow and understand a game of chess. Enter <a href="https://www.ibm.com/cloud/watson-assistant/">Watson Assistant</a> (formally conversation).</p><p>Lastly, we would need to be able to respond to players with speech. You guessed it: enter <a href="https://www.ibm.com/watson/services/text-to-speech/">Watson Text to Speech.</a></p><h3>Understanding Speech</h3><p>Using Watson Speech to Text, we were able to capture most of the audio and translate it accurately, even with the fact that we were mixing UK and US English accents. Pieces, colors and other elements were captured really well.</p><p>The board positions were a bit trickier, as they are not typical elements of language. We don’t say “D4” or “F8” very often in everyday speech. To deal with this, we used a custom voice model, Which is something that is covered in-depth in <a href="https://medium.com/@MissAmaraKay">Amara Graham (Keller)</a>’s article <a href="https://medium.com/@MissAmaraKay/how-to-build-a-custom-language-model-9cd75363f11b">How to Build a Custom Language Model</a>. We expanded this to load an entire JSON model, which we could add to over time as we gathered more detailed training data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82780a0fca0ebf585eebf01069708bb9/href">https://medium.com/media/82780a0fca0ebf585eebf01069708bb9/href</a></iframe><p>This caused a massive jump in the reliability of the Speech to Text system, showing how valuable it is to train Watson in your preferred domain language.</p><h3>Creating a conversational AI</h3><p>Using Watson Assistant, we were able to construct a dialog tree that gave our AI the knowledge of how to move through a chess game. Below, you can see an example of an “intent”, i.e. how the AI will act when it believes you want to make a move.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MnsVPFiIwNhbjW72C11_rg.png" /></figure><p>You can see that — as well as recognising the intent to move — it knows that it requires certain information, and will attempt to pull it out. You require a full PieceName (i.e. “Queen’s Rook”) or at least a PieceType (such as “Rook”) and we can infer which one from the board state. It also requires a place to move to. It will continue to prompt you for this information.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cb5a0e58e2244da4235c21802003e3b/href">https://medium.com/media/0cb5a0e58e2244da4235c21802003e3b/href</a></iframe><h3>Replying back with a voice</h3><p>Using Watson Text-To-Speech was a breeze, and the only real issue we hit was with our own programming.</p><p>We had slight issues with Watson tripping over its own speech. For example, Speech o Text would hear Text to Speech and the whole thing would end up talking to itself for a while.</p><p>The solution to this was relatively easy: we just kept the mic off while the Text to Speech was playing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc740345f3acfa200ea9473025b15097/href">https://medium.com/media/fc740345f3acfa200ea9473025b15097/href</a></iframe><h3>Giving Watson some smarts</h3><p>The focus of this was to try to make chess more accessible via a voice interface, not to build DeepBlue all over again. While we could have looked at <a href="https://www.ibm.com/cloud/machine-learning">Watson Machine Learning</a>, ee didn’t want to reinvent the wheel.</p><p>The simple solution was to convert outboard to Forsyth-Edwards Notation, and ask a chess engine for the answer over the Universal Chess Interface (UCI).</p><p>A list of this can be found on Wikipedia:</p><p><a href="https://en.wikipedia.org/wiki/Chess_engine">ttps://en.wikipedia.org/wiki/Chess_engine</a></p><h3>Results</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtLlcDczLfjw&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtLlcDczLfjw&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FtLlcDczLfjw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/83407c254bdf1779d9973fd2408f4cd3/href">https://medium.com/media/83407c254bdf1779d9973fd2408f4cd3/href</a></iframe><p>The results so far are really pleasing. We were able to build a powerful conversation interface, with understanding of domain specific language really fast.</p><p>Good future features would include:</p><ul><li>Having Watson comment on your move in more detail</li><li>Being able to ask Watson for hints</li><li>Being able to ask more general chess questions (maybe using Watson Discovery)</li></ul><p>We hope to open source this code very soon. In the meantime, to find out more please check out <a href="https://assetstore.unity.com/packages/tools/ai/ibm-watson-sdk-for-unity-108831">Watson Unity SDK</a> and <a href="https://www.emerging-technology.co.uk/">Emerging Tech Team.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58aa00f3d30f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>