{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":44254,"title":"Probability of red tulips (at both ends of a row)","description":"I planted tulip bulbs in a row on my flower bed.\r\nI thought that I had planted white tulips all. However, later, it turned out that two RED tulip bulbs had been mixed in the planted bulbs!\r\n\r\nInput (x): Number of all bulbs\r\n\r\nOutput (y): The probability that RED tulips will bloom at BOTH ENDs of the row.","description_html":"\u003cp\u003eI planted tulip bulbs in a row on my flower bed.\r\nI thought that I had planted white tulips all. However, later, it turned out that two RED tulip bulbs had been mixed in the planted bulbs!\u003c/p\u003e\u003cp\u003eInput (x): Number of all bulbs\u003c/p\u003e\u003cp\u003eOutput (y): The probability that RED tulips will bloom at BOTH ENDs of the row.\u003c/p\u003e","function_template":"function y = redT(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 3;\r\ny_correct = 1/3;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = 1/10;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n%%\r\nx= 8;\r\ny_correct = 1/28;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n%%\r\nx= 30;\r\ny_correct = 1/435;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":102298,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":65,"test_suite_updated_at":"2017-07-09T06:48:35.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-07-09T06:18:32.000Z","updated_at":"2026-03-16T09:51:51.000Z","published_at":"2017-07-09T06:48:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eI planted tulip bulbs in a row on my flower bed. I thought that I had planted white tulips all. However, later, it turned out that two RED tulip bulbs had been mixed in the planted bulbs!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput (x): Number of all bulbs\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput (y): The probability that RED tulips will bloom at BOTH ENDs of the row.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2770,"title":"Probability of Choosing a Red Ball","description":"Given two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps. \r\n\r\n  Step 1: Choose a random ball from Jar 2 and add it to Jar 1\r\n\r\n  Step 2: Choose a random ball from Jar 1\r\n\r\n  Step 3: Calculate the probability of the final ball being red\r\n\r\n*Example:* \r\n\r\nGiven inputs for Jar 1 and Jar 2\r\n\r\nJar 1: (r1,b1) = (2,7)\r\n\r\nJar 2: (r2,b2) = (5,5)\r\n\r\nChoose a ball from Jar 2 and add it to Jar 1. \r\n  \r\n   _Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._ \r\n\r\nTaking into consideration both possibilities, the likelihood of the final ball being red is *0.25* . ","description_html":"\u003cp\u003eGiven two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eStep 1: Choose a random ball from Jar 2 and add it to Jar 1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eStep 2: Choose a random ball from Jar 1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eStep 3: Calculate the probability of the final ball being red\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eGiven inputs for Jar 1 and Jar 2\u003c/p\u003e\u003cp\u003eJar 1: (r1,b1) = (2,7)\u003c/p\u003e\u003cp\u003eJar 2: (r2,b2) = (5,5)\u003c/p\u003e\u003cp\u003eChoose a ball from Jar 2 and add it to Jar 1.\u003c/p\u003e\u003cpre\u003e   _Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._ \u003c/pre\u003e\u003cp\u003eTaking into consideration both possibilities, the likelihood of the final ball being red is \u003cb\u003e0.25\u003c/b\u003e .\u003c/p\u003e","function_template":"function prob = probRedBall(r1,b1,r2,b2)\r\n  prob = r1/(r1+b1);\r\nend","test_suite":"%%\r\nr1 = 2; b1 = 7; r2 = 5; b2 = 5; \r\nprob_correct = 0.2500;\r\nassert(isequal(probRedBall(r1,b1,r2,b2),prob_correct))\r\n\r\n%%\r\nr1 = 0; b1 = 5; r2 = 0; b2 = 5; \r\nprob_correct = 0.0000;\r\nassert(isequal(probRedBall(r1,b1,r2,b2),prob_correct))\r\n\r\n%%\r\nr1 = 0; b1 = 3; r2 = 1; b2 = 3; \r\nprob_correct = 0.0625;\r\nassert(isequal(probRedBall(r1,b1,r2,b2),prob_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":32736,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":"2014-12-10T17:44:29.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-12-10T17:13:21.000Z","updated_at":"2026-03-05T15:56:58.000Z","published_at":"2014-12-10T17:35:42.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Step 1: Choose a random ball from Jar 2 and add it to Jar 1\\n\\nStep 2: Choose a random ball from Jar 1\\n\\nStep 3: Calculate the probability of the final ball being red]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven inputs for Jar 1 and Jar 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eJar 1: (r1,b1) = (2,7)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eJar 2: (r2,b2) = (5,5)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eChoose a ball from Jar 2 and add it to Jar 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   _Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTaking into consideration both possibilities, the likelihood of the final ball being red is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0.25\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":1268,"title":"Penny flipping - calculate winning probability (easy)","description":"Two players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game. \r\n\r\nCalculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.\r\n\r\nExample:\r\n\r\n  Input: m = 1, n =1\r\n  Output: 0.50","description_html":"\u003cp\u003eTwo players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game.\u003c/p\u003e\u003cp\u003eCalculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput: m = 1, n =1\r\nOutput: 0.50\r\n\u003c/pre\u003e","function_template":"function y = penny_flip(m, n)\r\n  y = m-n;\r\nend","test_suite":"%%\r\nm = 1;\r\nn = 1;\r\ny_correct = 0.50;\r\nassert(isequal(penny_flip(m, n),y_correct))\r\n\r\n%%\r\nm = 2;\r\nn = 2;\r\ny_correct = 0.50;\r\nassert(isequal(penny_flip(m, n),y_correct))\r\n\r\n%%\r\nm = 1e6;\r\nn = 1e6;\r\ny_correct = 0.50;\r\nassert(isequal(penny_flip(m, n),y_correct))\r\n\r\n%%\r\nm = 4;\r\nn = 2;\r\ny_correct = 2/3;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n\r\n%%\r\nm = 2;\r\nn = 4;\r\ny_correct = 1/3;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n\r\n%%\r\nm = 106;\r\nn = 47;\r\ny_correct = 0.6928;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n\r\n%%\r\nm = 3;\r\nn = 4;\r\ny_correct = 0.4286;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":2,"created_by":10338,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":196,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-02-13T03:59:39.000Z","updated_at":"2026-02-25T10:33:14.000Z","published_at":"2013-02-13T03:59:39.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTwo players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Input: m = 1, n =1\\nOutput: 0.50]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42485,"title":"Eliminate Outliers Using Interquartile Range","description":"Given a vector with your \"data\" find the outliers and remove them.\r\n\r\nTo determine whether data contains an outlier:\r\n\r\n# Identify the point furthest from the mean of the data.\r\n# Determine whether that point is further than 1.5*IQR away from the mean.\r\n# If so, that point is an outlier and should be eliminated from the data resulting in a new set of data.\r\n# Repeat steps to determine if new data set contains an outlier until dataset no longer contains outlier.\r\n\r\nIQR: Interquartile Range is the range between the median of the upper half and the median of the lower half of data: http://www.wikihow.com/Find-the-IQR\r\n\r\nTo find an outlier by hand:\r\n\r\nData:  [ 53 55 51 50 60 52 ] we will check for outliers.\r\n\r\nSorted: [ 50 *51* 52 53 *55* 60 ]   where the mean is 53.5 and 60 is the furthest away (60-53.5 \u003e 53.5-50).\r\n\r\n1.5 * IQR = 1.5 * (55-51) = 6\r\n\r\nSince 60-53.5 = 6.5 \u003e 6, 60 is an outlier.\r\n\r\nNew Data: [ 53 55 51 50 52 ] we will check for outliers.\r\n\r\nNew Data Sorted: [ *50 51* 52 *53 55* ] where the mean is 52.2 and 55 is the furthest away.\r\n\r\n1.5* IQR = 1.5 * (54-50.5) = 4.5\r\n\r\nSince 55-52.2 = 2.8 \u003c 4.5, 55 is NOT an outlier.\r\n\r\nOur original data had one outlier, which was 60.\r\n\r\nExample:\r\n\r\n  Input data = [53 55 51 50 60 52]\r\n  \r\n  Output new_data = [53 55 51 50 52]\r\n\r\nsince 60 is an outlier, it is removed\r\n\r\n**Note: A number may be repeated within a dataset that is an outlier. You should not remove all instances, but remove only the first instance and check the new dataset to determine whether this number is still an outlier (see 5th test suite).**","description_html":"\u003cp\u003eGiven a vector with your \"data\" find the outliers and remove them.\u003c/p\u003e\u003cp\u003eTo determine whether data contains an outlier:\u003c/p\u003e\u003col\u003e\u003cli\u003eIdentify the point furthest from the mean of the data.\u003c/li\u003e\u003cli\u003eDetermine whether that point is further than 1.5*IQR away from the mean.\u003c/li\u003e\u003cli\u003eIf so, that point is an outlier and should be eliminated from the data resulting in a new set of data.\u003c/li\u003e\u003cli\u003eRepeat steps to determine if new data set contains an outlier until dataset no longer contains outlier.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eIQR: Interquartile Range is the range between the median of the upper half and the median of the lower half of data: \u003ca href = \"http://www.wikihow.com/Find-the-IQR\"\u003ehttp://www.wikihow.com/Find-the-IQR\u003c/a\u003e\u003c/p\u003e\u003cp\u003eTo find an outlier by hand:\u003c/p\u003e\u003cp\u003eData:  [ 53 55 51 50 60 52 ] we will check for outliers.\u003c/p\u003e\u003cp\u003eSorted: [ 50 \u003cb\u003e51\u003c/b\u003e 52 53 \u003cb\u003e55\u003c/b\u003e 60 ]   where the mean is 53.5 and 60 is the furthest away (60-53.5 \u0026gt; 53.5-50).\u003c/p\u003e\u003cp\u003e1.5 * IQR = 1.5 * (55-51) = 6\u003c/p\u003e\u003cp\u003eSince 60-53.5 = 6.5 \u0026gt; 6, 60 is an outlier.\u003c/p\u003e\u003cp\u003eNew Data: [ 53 55 51 50 52 ] we will check for outliers.\u003c/p\u003e\u003cp\u003eNew Data Sorted: [ \u003cb\u003e50 51\u003c/b\u003e 52 \u003cb\u003e53 55\u003c/b\u003e ] where the mean is 52.2 and 55 is the furthest away.\u003c/p\u003e\u003cp\u003e1.5* IQR = 1.5 * (54-50.5) = 4.5\u003c/p\u003e\u003cp\u003eSince 55-52.2 = 2.8 \u0026lt; 4.5, 55 is NOT an outlier.\u003c/p\u003e\u003cp\u003eOur original data had one outlier, which was 60.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput data = [53 55 51 50 60 52]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eOutput new_data = [53 55 51 50 52]\r\n\u003c/pre\u003e\u003cp\u003esince 60 is an outlier, it is removed\u003c/p\u003e\u003cp\u003e\u003cb\u003e*Note: A number may be repeated within a dataset that is an outlier. You should not remove all instances, but remove only the first instance and check the new dataset to determine whether this number is still an outlier (see 5th test suite).*\u003c/b\u003e\u003c/p\u003e","function_template":"function new_data = remove_outlier(data)\r\n  new_data = data;\r\nend","test_suite":"%%\r\ndata = [53,55,51,50,60,52];\r\ncorrect_data = [53,55,51,50,52];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [0,0,0,0,0];\r\ncorrect_data = [0,0,0,0,0];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [1,2,3,4,5,100,100,6,7,8];\r\ncorrect_data = [1,2,3,4,5,6,7,8];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [-54,-30,-45,-40,0,-33];\r\ncorrect_data = [-54,-30,-45,-40,-33];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [63,64,64,63,53,61,65,63,52,50,65,61,68,137,62,60,64,67,65,63,63,63];\r\ncorrect_data = [63,64,64,63,65,63,65,62,64,65,63,63,63];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [1,2,3,4,5,6,7];\r\ncorrect_data = [1,2,3,4,5,6,7];\r\nassert(isequal(remove_outlier(data),correct_data))","published":true,"deleted":false,"likes_count":3,"comments_count":7,"created_by":47261,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":"2015-08-04T14:24:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-08-03T19:32:53.000Z","updated_at":"2025-11-21T18:38:11.000Z","published_at":"2015-08-03T19:41:30.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector with your \\\"data\\\" find the outliers and remove them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo determine whether data contains an outlier:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIdentify the point furthest from the mean of the data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDetermine whether that point is further than 1.5*IQR away from the mean.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf so, that point is an outlier and should be eliminated from the data resulting in a new set of data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRepeat steps to determine if new data set contains an outlier until dataset no longer contains outlier.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIQR: Interquartile Range is the range between the median of the upper half and the median of the lower half of data:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.wikihow.com/Find-the-IQR\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.wikihow.com/Find-the-IQR\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo find an outlier by hand:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eData: [ 53 55 51 50 60 52 ] we will check for outliers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSorted: [ 50\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e51\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 52 53\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e55\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 60 ] where the mean is 53.5 and 60 is the furthest away (60-53.5 \u0026gt; 53.5-50).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1.5 * IQR = 1.5 * (55-51) = 6\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince 60-53.5 = 6.5 \u0026gt; 6, 60 is an outlier.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNew Data: [ 53 55 51 50 52 ] we will check for outliers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNew Data Sorted: [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e50 51\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 52\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e53 55\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ] where the mean is 52.2 and 55 is the furthest away.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1.5* IQR = 1.5 * (54-50.5) = 4.5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince 55-52.2 = 2.8 \u0026lt; 4.5, 55 is NOT an outlier.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOur original data had one outlier, which was 60.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Input data = [53 55 51 50 60 52]\\n\\nOutput new_data = [53 55 51 50 52]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003esince 60 is an outlier, it is removed\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e*Note: A number may be repeated within a dataset that is an outlier. You should not remove all instances, but remove only the first instance and check the new dataset to determine whether this number is still an outlier (see 5th test suite).\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e*\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44254,"title":"Probability of red tulips (at both ends of a row)","description":"I planted tulip bulbs in a row on my flower bed.\r\nI thought that I had planted white tulips all. However, later, it turned out that two RED tulip bulbs had been mixed in the planted bulbs!\r\n\r\nInput (x): Number of all bulbs\r\n\r\nOutput (y): The probability that RED tulips will bloom at BOTH ENDs of the row.","description_html":"\u003cp\u003eI planted tulip bulbs in a row on my flower bed.\r\nI thought that I had planted white tulips all. However, later, it turned out that two RED tulip bulbs had been mixed in the planted bulbs!\u003c/p\u003e\u003cp\u003eInput (x): Number of all bulbs\u003c/p\u003e\u003cp\u003eOutput (y): The probability that RED tulips will bloom at BOTH ENDs of the row.\u003c/p\u003e","function_template":"function y = redT(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 3;\r\ny_correct = 1/3;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = 1/10;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n%%\r\nx= 8;\r\ny_correct = 1/28;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n%%\r\nx= 30;\r\ny_correct = 1/435;\r\nassert(isequal(redT(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":102298,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":65,"test_suite_updated_at":"2017-07-09T06:48:35.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-07-09T06:18:32.000Z","updated_at":"2026-03-16T09:51:51.000Z","published_at":"2017-07-09T06:48:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eI planted tulip bulbs in a row on my flower bed. I thought that I had planted white tulips all. However, later, it turned out that two RED tulip bulbs had been mixed in the planted bulbs!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eInput (x): Number of all bulbs\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput (y): The probability that RED tulips will bloom at BOTH ENDs of the row.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2770,"title":"Probability of Choosing a Red Ball","description":"Given two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps. \r\n\r\n  Step 1: Choose a random ball from Jar 2 and add it to Jar 1\r\n\r\n  Step 2: Choose a random ball from Jar 1\r\n\r\n  Step 3: Calculate the probability of the final ball being red\r\n\r\n*Example:* \r\n\r\nGiven inputs for Jar 1 and Jar 2\r\n\r\nJar 1: (r1,b1) = (2,7)\r\n\r\nJar 2: (r2,b2) = (5,5)\r\n\r\nChoose a ball from Jar 2 and add it to Jar 1. \r\n  \r\n   _Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._ \r\n\r\nTaking into consideration both possibilities, the likelihood of the final ball being red is *0.25* . ","description_html":"\u003cp\u003eGiven two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eStep 1: Choose a random ball from Jar 2 and add it to Jar 1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eStep 2: Choose a random ball from Jar 1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eStep 3: Calculate the probability of the final ball being red\r\n\u003c/pre\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eGiven inputs for Jar 1 and Jar 2\u003c/p\u003e\u003cp\u003eJar 1: (r1,b1) = (2,7)\u003c/p\u003e\u003cp\u003eJar 2: (r2,b2) = (5,5)\u003c/p\u003e\u003cp\u003eChoose a ball from Jar 2 and add it to Jar 1.\u003c/p\u003e\u003cpre\u003e   _Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._ \u003c/pre\u003e\u003cp\u003eTaking into consideration both possibilities, the likelihood of the final ball being red is \u003cb\u003e0.25\u003c/b\u003e .\u003c/p\u003e","function_template":"function prob = probRedBall(r1,b1,r2,b2)\r\n  prob = r1/(r1+b1);\r\nend","test_suite":"%%\r\nr1 = 2; b1 = 7; r2 = 5; b2 = 5; \r\nprob_correct = 0.2500;\r\nassert(isequal(probRedBall(r1,b1,r2,b2),prob_correct))\r\n\r\n%%\r\nr1 = 0; b1 = 5; r2 = 0; b2 = 5; \r\nprob_correct = 0.0000;\r\nassert(isequal(probRedBall(r1,b1,r2,b2),prob_correct))\r\n\r\n%%\r\nr1 = 0; b1 = 3; r2 = 1; b2 = 3; \r\nprob_correct = 0.0625;\r\nassert(isequal(probRedBall(r1,b1,r2,b2),prob_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":32736,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":"2014-12-10T17:44:29.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2014-12-10T17:13:21.000Z","updated_at":"2026-03-05T15:56:58.000Z","published_at":"2014-12-10T17:35:42.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Step 1: Choose a random ball from Jar 2 and add it to Jar 1\\n\\nStep 2: Choose a random ball from Jar 1\\n\\nStep 3: Calculate the probability of the final ball being red]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven inputs for Jar 1 and Jar 2\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eJar 1: (r1,b1) = (2,7)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eJar 2: (r2,b2) = (5,5)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eChoose a ball from Jar 2 and add it to Jar 1.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   _Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTaking into consideration both possibilities, the likelihood of the final ball being red is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e0.25\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":1268,"title":"Penny flipping - calculate winning probability (easy)","description":"Two players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game. \r\n\r\nCalculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.\r\n\r\nExample:\r\n\r\n  Input: m = 1, n =1\r\n  Output: 0.50","description_html":"\u003cp\u003eTwo players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game.\u003c/p\u003e\u003cp\u003eCalculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput: m = 1, n =1\r\nOutput: 0.50\r\n\u003c/pre\u003e","function_template":"function y = penny_flip(m, n)\r\n  y = m-n;\r\nend","test_suite":"%%\r\nm = 1;\r\nn = 1;\r\ny_correct = 0.50;\r\nassert(isequal(penny_flip(m, n),y_correct))\r\n\r\n%%\r\nm = 2;\r\nn = 2;\r\ny_correct = 0.50;\r\nassert(isequal(penny_flip(m, n),y_correct))\r\n\r\n%%\r\nm = 1e6;\r\nn = 1e6;\r\ny_correct = 0.50;\r\nassert(isequal(penny_flip(m, n),y_correct))\r\n\r\n%%\r\nm = 4;\r\nn = 2;\r\ny_correct = 2/3;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n\r\n%%\r\nm = 2;\r\nn = 4;\r\ny_correct = 1/3;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n\r\n%%\r\nm = 106;\r\nn = 47;\r\ny_correct = 0.6928;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n\r\n%%\r\nm = 3;\r\nn = 4;\r\ny_correct = 0.4286;\r\nassert(abs(penny_flip(m, n)-y_correct) \u003c= 0.01)\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":2,"created_by":10338,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":196,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-02-13T03:59:39.000Z","updated_at":"2026-02-25T10:33:14.000Z","published_at":"2013-02-13T03:59:39.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTwo players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/her collection. This continues until one player runs out of pennies and loses the game.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCalculate the probability of winning for the first player, given the first player's number of coins, m, and the second player's number of coins, n.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Input: m = 1, n =1\\nOutput: 0.50]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":42485,"title":"Eliminate Outliers Using Interquartile Range","description":"Given a vector with your \"data\" find the outliers and remove them.\r\n\r\nTo determine whether data contains an outlier:\r\n\r\n# Identify the point furthest from the mean of the data.\r\n# Determine whether that point is further than 1.5*IQR away from the mean.\r\n# If so, that point is an outlier and should be eliminated from the data resulting in a new set of data.\r\n# Repeat steps to determine if new data set contains an outlier until dataset no longer contains outlier.\r\n\r\nIQR: Interquartile Range is the range between the median of the upper half and the median of the lower half of data: http://www.wikihow.com/Find-the-IQR\r\n\r\nTo find an outlier by hand:\r\n\r\nData:  [ 53 55 51 50 60 52 ] we will check for outliers.\r\n\r\nSorted: [ 50 *51* 52 53 *55* 60 ]   where the mean is 53.5 and 60 is the furthest away (60-53.5 \u003e 53.5-50).\r\n\r\n1.5 * IQR = 1.5 * (55-51) = 6\r\n\r\nSince 60-53.5 = 6.5 \u003e 6, 60 is an outlier.\r\n\r\nNew Data: [ 53 55 51 50 52 ] we will check for outliers.\r\n\r\nNew Data Sorted: [ *50 51* 52 *53 55* ] where the mean is 52.2 and 55 is the furthest away.\r\n\r\n1.5* IQR = 1.5 * (54-50.5) = 4.5\r\n\r\nSince 55-52.2 = 2.8 \u003c 4.5, 55 is NOT an outlier.\r\n\r\nOur original data had one outlier, which was 60.\r\n\r\nExample:\r\n\r\n  Input data = [53 55 51 50 60 52]\r\n  \r\n  Output new_data = [53 55 51 50 52]\r\n\r\nsince 60 is an outlier, it is removed\r\n\r\n**Note: A number may be repeated within a dataset that is an outlier. You should not remove all instances, but remove only the first instance and check the new dataset to determine whether this number is still an outlier (see 5th test suite).**","description_html":"\u003cp\u003eGiven a vector with your \"data\" find the outliers and remove them.\u003c/p\u003e\u003cp\u003eTo determine whether data contains an outlier:\u003c/p\u003e\u003col\u003e\u003cli\u003eIdentify the point furthest from the mean of the data.\u003c/li\u003e\u003cli\u003eDetermine whether that point is further than 1.5*IQR away from the mean.\u003c/li\u003e\u003cli\u003eIf so, that point is an outlier and should be eliminated from the data resulting in a new set of data.\u003c/li\u003e\u003cli\u003eRepeat steps to determine if new data set contains an outlier until dataset no longer contains outlier.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eIQR: Interquartile Range is the range between the median of the upper half and the median of the lower half of data: \u003ca href = \"http://www.wikihow.com/Find-the-IQR\"\u003ehttp://www.wikihow.com/Find-the-IQR\u003c/a\u003e\u003c/p\u003e\u003cp\u003eTo find an outlier by hand:\u003c/p\u003e\u003cp\u003eData:  [ 53 55 51 50 60 52 ] we will check for outliers.\u003c/p\u003e\u003cp\u003eSorted: [ 50 \u003cb\u003e51\u003c/b\u003e 52 53 \u003cb\u003e55\u003c/b\u003e 60 ]   where the mean is 53.5 and 60 is the furthest away (60-53.5 \u0026gt; 53.5-50).\u003c/p\u003e\u003cp\u003e1.5 * IQR = 1.5 * (55-51) = 6\u003c/p\u003e\u003cp\u003eSince 60-53.5 = 6.5 \u0026gt; 6, 60 is an outlier.\u003c/p\u003e\u003cp\u003eNew Data: [ 53 55 51 50 52 ] we will check for outliers.\u003c/p\u003e\u003cp\u003eNew Data Sorted: [ \u003cb\u003e50 51\u003c/b\u003e 52 \u003cb\u003e53 55\u003c/b\u003e ] where the mean is 52.2 and 55 is the furthest away.\u003c/p\u003e\u003cp\u003e1.5* IQR = 1.5 * (54-50.5) = 4.5\u003c/p\u003e\u003cp\u003eSince 55-52.2 = 2.8 \u0026lt; 4.5, 55 is NOT an outlier.\u003c/p\u003e\u003cp\u003eOur original data had one outlier, which was 60.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput data = [53 55 51 50 60 52]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eOutput new_data = [53 55 51 50 52]\r\n\u003c/pre\u003e\u003cp\u003esince 60 is an outlier, it is removed\u003c/p\u003e\u003cp\u003e\u003cb\u003e*Note: A number may be repeated within a dataset that is an outlier. You should not remove all instances, but remove only the first instance and check the new dataset to determine whether this number is still an outlier (see 5th test suite).*\u003c/b\u003e\u003c/p\u003e","function_template":"function new_data = remove_outlier(data)\r\n  new_data = data;\r\nend","test_suite":"%%\r\ndata = [53,55,51,50,60,52];\r\ncorrect_data = [53,55,51,50,52];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [0,0,0,0,0];\r\ncorrect_data = [0,0,0,0,0];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [1,2,3,4,5,100,100,6,7,8];\r\ncorrect_data = [1,2,3,4,5,6,7,8];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [-54,-30,-45,-40,0,-33];\r\ncorrect_data = [-54,-30,-45,-40,-33];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [63,64,64,63,53,61,65,63,52,50,65,61,68,137,62,60,64,67,65,63,63,63];\r\ncorrect_data = [63,64,64,63,65,63,65,62,64,65,63,63,63];\r\nassert(isequal(remove_outlier(data),correct_data))\r\n\r\n%%\r\ndata = [1,2,3,4,5,6,7];\r\ncorrect_data = [1,2,3,4,5,6,7];\r\nassert(isequal(remove_outlier(data),correct_data))","published":true,"deleted":false,"likes_count":3,"comments_count":7,"created_by":47261,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":28,"test_suite_updated_at":"2015-08-04T14:24:26.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-08-03T19:32:53.000Z","updated_at":"2025-11-21T18:38:11.000Z","published_at":"2015-08-03T19:41:30.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a vector with your \\\"data\\\" find the outliers and remove them.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo determine whether data contains an outlier:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIdentify the point furthest from the mean of the data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eDetermine whether that point is further than 1.5*IQR away from the mean.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf so, that point is an outlier and should be eliminated from the data resulting in a new set of data.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRepeat steps to determine if new data set contains an outlier until dataset no longer contains outlier.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIQR: Interquartile Range is the range between the median of the upper half and the median of the lower half of data:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.wikihow.com/Find-the-IQR\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.wikihow.com/Find-the-IQR\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTo find an outlier by hand:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eData: [ 53 55 51 50 60 52 ] we will check for outliers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSorted: [ 50\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e51\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 52 53\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e55\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 60 ] where the mean is 53.5 and 60 is the furthest away (60-53.5 \u0026gt; 53.5-50).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1.5 * IQR = 1.5 * (55-51) = 6\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince 60-53.5 = 6.5 \u0026gt; 6, 60 is an outlier.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNew Data: [ 53 55 51 50 52 ] we will check for outliers.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNew Data Sorted: [\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e50 51\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e 52\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e53 55\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ] where the mean is 52.2 and 55 is the furthest away.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e1.5* IQR = 1.5 * (54-50.5) = 4.5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSince 55-52.2 = 2.8 \u0026lt; 4.5, 55 is NOT an outlier.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOur original data had one outlier, which was 60.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[Input data = [53 55 51 50 60 52]\\n\\nOutput new_data = [53 55 51 50 52]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003esince 60 is an outlier, it is removed\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e*Note: A number may be repeated within a dataset that is an outlier. You should not remove all instances, but remove only the first instance and check the new dataset to determine whether this number is still an outlier (see 5th test suite).\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e*\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Probability \u0026 Stats\"","","\"","Probability \u0026 Stats","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:easy","","","easy",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f30349d7a90\u003e":["Probability \u0026 Stats"],"#\u003cMathWorks::Search::Field:0x00007f30349d79f0\u003e":["easy"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f30349d7130\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f30349d7d10\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f30349d7c70\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f30349d7bd0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f30349d7b30\u003e":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f30349d7b30\u003e":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f30349d7a90\u003e":["Probability \u0026 Stats"],"#\u003cMathWorks::Search::Field:0x00007f30349d79f0\u003e":["easy"]}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Probability \u0026 Stats\"","","\"","Probability \u0026 Stats","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:easy","","","easy",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f30349d7a90\u003e":["Probability \u0026 Stats"],"#\u003cMathWorks::Search::Field:0x00007f30349d79f0\u003e":["easy"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f30349d7130\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f30349d7d10\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f30349d7c70\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f30349d7bd0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f30349d7b30\u003e":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f30349d7b30\u003e":"group:\"Probability \u0026 Stats\" difficulty_rating_bin:easy"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f30349d7a90\u003e":["Probability \u0026 Stats"],"#\u003cMathWorks::Search::Field:0x00007f30349d79f0\u003e":["easy"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44254,"difficulty_rating":"easy"},{"id":2770,"difficulty_rating":"easy"},{"id":1268,"difficulty_rating":"easy"},{"id":42485,"difficulty_rating":"easy"}]}}