{"id":156,"date":"2014-04-22T06:27:00","date_gmt":"2014-04-22T06:27:00","guid":{"rendered":"http:\/\/128.199.128.224\/random-thoughts\/"},"modified":"2017-10-05T07:46:04","modified_gmt":"2017-10-04T22:46:04","slug":"random-thoughts","status":"publish","type":"post","link":"https:\/\/naganashi.com\/kanjiflow\/random-thoughts\/","title":{"rendered":"Random Thoughts"},"content":{"rendered":"<p>This is going to be another boring post. It\u2019s specifically regarding how the app shuffles cards and randomness in general but its also going to get into things like statistics and heuristics.<\/p>\n<p>The short story is that new cards show up in order during their first study session. This is because I like to edit my cards from the Study View and I\u2019m usually working from a list. If you don\u2019t want new cards to show up in order there is a setting you can enable to randomize them. For cards that are not new, I use <code>arc4random_uniform([array count])<\/code> to choose random numbers and a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fisher\u2013Yates_shuffle\" target=\"_blank\" rel=\"noopener\">Fisher-Yates shuffle<\/a> to actually shuffle the cards. Even though these procedures may seem to be the best and\/or most standard ways of getting random numbers and shuffling a set, you might still notice patterns and\/or the resulting shuffles might not seem random to you. How can that be?<\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Law_of_large_numbers\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"aligncenter\" style=\"background: white;\" src=\"https:\/\/naganashi.com\/kanjiflow\/wp-content\/uploads\/sites\/2\/2017\/03\/largeNumbers.png\" alt=\"\" \/><\/a><\/p>\n<p>Computers are not really capable of choosing things at random. Generally speaking, when one asks a computer to generate a random number it must go through some process to create that number. It might use the current time or some other internally-known condition (voltage, temperature, etc.) as a basis for generating the number. If we could recreate the precise condition or conditions that existed in a system when it generated a random number, we could cause that system to generate the same random number over and over again. That\u2019s not truly random. The same thing is true of the universe. If you precisely reproduce the conditions of the universe (and I mean the precise position, velocity, and spin of every fundamental particle in existence), you will always get the same outcome (quantum fluctuations not withstanding). Even though you may think you have free will, you wouldn\u2019t be able to change your mind if everything were <em>precisely<\/em> the same. Given the same conditions, you must always choose Pepsi instead of Coke. Given the <em>same<\/em> conditions.<\/p>\n<p>I personally prefer Coke, by the way. But there must be some conditions that would cause me to choose Pepsi. I can\u2019t really imagine what those conditions might be but if they existed, I must choose Pepsi. And if we recreated those conditions precisely through many trials, I would choose Pepsi every time. Get it? I would not be able to change my mind.<\/p>\n<p>But, can that really be true? Certainly, you can change your mind and random things do happen all the time, right? Well, now we\u2019re getting into a philosophical debate. What does random mean? Does it mean something that seems random to people and not something that is actually random in the mathematical sense? If we\u2019re only concerned about things that seem random to people then, yes, randomness does exists. If we\u2019re talking about mathematical randomness\u2026actually, I\u2019m not sure.<\/p>\n<p>I think truly random things may not exist (again, ignoring the quantum world) but what we can do is try to reach a state of being as random as possible and call that state mathematical randomness. It\u2019s just like circles. While we can mathematically describe a circle, in fact there seem to be none. There seems to be nothing in existence that is actually round. There are very round things. Things that are so round that they are almost truly round. Things like the sun &#8211; the roundest thing we know of. But we are capable of measuring the fact that it is not round. What we mean when we call something round is that it is round enough to be practically round. What I mean when I say random is just random enough to be practically random.<\/p>\n<p>So, let us ignore the possibility that randomness may not even truly be possible. Let\u2019s just establish a model with two phrases: <em>seems to be random<\/em> and <em>mathematically random<\/em>. Seems to be random will simply mean that it\u2019s difficult for the average person to notice a pattern and mathematically random will mean that it\u2019s actually approaching a smooth distribution curve.<\/p>\n<p>When I implement a random function, such as a function that should shuffle or choose virtual flashcards at random, do I want mathematical randomness or do I want something that seems random to people? Well, wait a second. Shouldn\u2019t that be the same thing? If it\u2019s as random, or pseudo-random as it were, as it\u2019s possible for a computer to be, won\u2019t that also seem random to people?<\/p>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"525\" height=\"296\" src=\"https:\/\/www.youtube.com\/embed\/mEN7DTdHbAU?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<p>Almost certainly not. Humans, generally speaking, are horrible at statistics. We do not have a natural affinity for it. What we do have a natural affinity for is patterns. We seek them out. Visual patterns such as faces. We see them where they do not exist. We see faces in burnt toast and in clouds and in mountain shadows on Mars. There are no faces there but <a href=\"http:\/\/en.wikipedia.org\/wiki\/Pareidolia\" target=\"_blank\" rel=\"noopener\">we see them all the same<\/a>. We also seek out numerical patterns. No, I\u2019m not talking about those math problems from your tests in junior high school. I\u2019m referring to numerical patterns that we may not even realize are related to numbers and\/or statistics such as patterns in the occurrence of events.<\/p>\n<p>There is a very good reason for this pattern seeking behavior. It\u2019s so you don\u2019t have to waste time and energy actually using your brain to think about things all the time. Your brain is an amazing piece of biological machinery. And like many other amazing pieces of machinery, it\u2019s an energy hog. Despite what you may have heard or read elsewhere, unless you had a developmental abnormality or some sort of inadvertent head trauma, you use 100% of it at almost all times and it consumes as much as 30% of the energy your digestive system extracts from the food you eat. Actually, I\u2019m not sure about that energy number as I\u2019ve seen estimates ranging from 20-25% and heard seemingly well-informed people mention numbers as high as 30%. Anyway, it is the single most draining organ that you posses. That\u2019s good because it makes you really smart. But it\u2019s also kinda bad because it consumes a lot of energy. Because of this, it has various built-in efficiency systems that it makes use of in order to keep the amount of energy it requires to a minimum.<\/p>\n<p>One of these systems or perhaps series of systems manifests itself as something known as <a href=\"http:\/\/en.wikipedia.org\/wiki\/Heuristic\" target=\"_blank\" rel=\"noopener\">heuristics<\/a>. This goes directly back to patterns in the occurrence of events. It\u2019s quite simple to see A and then B and know that A caused B. Especially if we see this sequence occur over and over again. A and B may in fact be completely unrelated or due to some unobserved and unknown third condition but heuristics might cause us to simply link A and B. Likewise, if I see A, B, and then C and notice some similarity or relationship between the three (for example, they\u2019re the first three letters of the Roman alphabet in order) then I might have a tendency to think that something fishy is going on if I had been told that I would be shown random letters.<\/p>\n<p>But is it really fishy? Can I deduce fishiness after seeing only three trials? What\u2019s the likelihood or mathematical probability that you would get A, B, and then C randomly? Certainly, it\u2019s not 0 but I don\u2019t know what the actual probability is because I\u2019m not good at statistics. I could work it out but that\u2019s not the point. The point is, I can\u2019t immediately see the answer or even easily find it after a bit of thought. I would have to really think about it. Perhaps even get out a pencil and sheet of paper to figure it out.<\/p>\n<p>I don\u2019t think that you can really figure out anything statistically speaking after only three trials. In fact, you would probably need to see quite a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Law_of_large_numbers\" target=\"_blank\" rel=\"noopener\">large number<\/a> of trials in order to get a good spread. The more the better. So, if you notice that a few of your cards show up in order or near each other or in reverse order or whatever pattern you happen to notice, what does that mean? What if the same pattern occurs twice in a row? Despite the fact that you may feel like something strange is going on, it\u2019s probably quite normal. Even unlikely things have some probability associated with them. The fact that they are not impossible means that they must eventually occur. If you really want to show that something fishy is going on, do a thousand or so trials, work out the probability spread that you observed and compare it to what you would consider random. You\u2019ll probably notice that there\u2019s only a few tenths of a percentage difference between what you would expect and what you actually observed. Which would mean&#8230;nothing fishy.<\/p>\n<p>I could implement checks to make sure that the seemingly fishy things don\u2019t occur. I could make sure cards don\u2019t get shuffled back into their original positions. I could ensure that cards that were created within a short interval of each other or cards that feature the same kanji don\u2019t get shuffled into positions near each other. I could ensure that the same patterns that occurred in a previous shuffle don\u2019t occur in subsequent shuffles. However, doing these things would actually make the shuffles <em>less<\/em> random. It would seem more random to the casual observer but these arbitrary tricks would actually destroy the overall distribution. So, even though seemingly fishy things might (or almost certainly will) occur, <del datetime=\"2017-09-28T14:43:00+00:00\">I think I\u2019m going to just leave the current implementation as is<\/del>. It may not seem very random but I actually think that means it\u2019s approaching the standard of randomness I would prefer to see.<\/p>\n<p><strong>Happy studies!<\/strong><\/p>\n<p><em>What the user wants&#8230;the user will get: <a href=\"https:\/\/naganashi.com\/kanjiflow\/version-227-released\/\">Study Due Variance<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is going to be another boring post. It\u2019s specifically regarding how the app shuffles cards and randomness in general but its also going to get into things like statistics and heuristics. The short story is that new cards show up in order during their first study session. This is because I like to edit &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/naganashi.com\/kanjiflow\/random-thoughts\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Random Thoughts&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[60],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-blog","tag-sorting"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8yq3B-2w","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":6,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/posts\/156\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naganashi.com\/kanjiflow\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}