{"id":46740,"date":"2022-12-16T00:00:00","date_gmt":"2022-12-16T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"},"modified":"2025-11-13T12:56:24","modified_gmt":"2025-11-13T20:56:24","slug":"analysis-of-the-swisslos-lottery-using-r-and-griddb","status":"publish","type":"post","link":"https:\/\/griddb.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","title":{"rendered":"Analysis of the Swisslos lottery using R and GridDB"},"content":{"rendered":"<p>A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that their chosen numbers will be drawn.<\/p>\n<p>Of course, unless the lottery is rigged, that is not the case. Most will realize that every number and every combination of numbers has the same likelihood. However &#8211; and this is the exciting part &#8211; not every combination has the same expected value.<\/p>\n<p>Our idea is this: Because some people are superstitious, and humans are bad at picking numbers randomly, there will be numbers that gamblers play much more frequently than other numbers. If we can play the numbers that other people are least likely to play, we expect to win more money because if we do actually win, the pot will be split among fewer people.<\/p>\n<p>So, it is true that some numbers will make more money in the long run. By making more money, we mean you\u2019d lose money at a slower rate than the average lottery player; you\u2019d still lose money.<\/p>\n<p>Full source code can be found here: https:\/\/github.com\/retowyss\/swisslos-r-griddb\/<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">$ git clone https:\/\/github.com\/retowyss\/swisslos-r-griddb.git <\/code><\/pre>\n<\/div>\n<h2>Data Overview and Analysis Tools<\/h2>\n<p>We analyze approximately seven years of lottery drawings (n = 720, start = 2013-01-12, end = 2019-12-04) from \u201cSwisslos,\u201d the national lottery of Switzerland, using the statistical programming language R, and we use GridDB for our data storage.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># Required packages RJDBC and tidyverse \n# griddb is the connection object to our GridDB\n\ndrv &lt;- JDBC(\n  driverClass = \"com.toshiba.mwcloud.gs.sql.Driver\",\n  # Point this to your gridstore jar\n  classPath = \"\/jdbc\/bin\/gridstore-jdbc.jar\"\n)\n\n# IP and port depend on your setup\ngriddb &lt;- dbConnect(\n  drv, \n  \"jdbc:gs:\/\/172.20.0.42:20001\/dockerGridDB\/public\", \n  \"admin\", \n  \"admin\"\n)\n\n# vectorized insert function\ndbInsertTable &lt;- function(conn, name, df, append = TRUE) {\n  for (i in seq_len(nrow(df))) {\n    dbWriteTable(conn, name, df[i, ], append = append)\n  }\n}\n\ndbSendUpdate(griddb, paste(\n  \"CREATE TABLE IF NOT EXISTS swisslos_jackpots\", \n  \"(date STRING, jackpot INTEGER);\"\n))\ndbInsertTable(griddb, \"swisslos_jackpots\", read_csv(\"data\/swisslos_jackpots.csv\"))\n\n\ndbSendUpdate(griddb, paste(\n  \"CREATE TABLE IF NOT EXISTS swisslos_payouts\", \n  \"(combination STRING, winners INTEGER, prize FLOAT, date STRING);\"\n))\ndbInsertTable(griddb, \"swisslos_payouts\", read_csv(\"data\/swisslos_payouts.csv\"))\n\n\ndbSendUpdate(griddb, paste(\n  \"CREATE TABLE IF NOT EXISTS swisslos_numbers\", \n  \"(type STRING, number INTEGER, date STRING);\"  \n))\ndbInsertTable(griddb, \"swisslos_numbers\", read_csv(\"data\/swisslos_numbers.csv\"))<\/code><\/pre>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\">dbListTables(griddb)<\/code><\/pre>\n<\/div>\n<pre><code>## [1] \"swisslos_jackpots\" \"swisslos_numbers\"  \"swisslos_payouts\"\n<\/code><\/pre>\n<ul>\n<li>Jackpot sizes (swisslos_jackpots) <\/li>\n<\/ul>\n<ol style=\"list-style-type: decimal\">\n<li>\n    date\n  <\/li>\n<li>\n    jackpot: maximum payout (CHF) for 6 + 1\n  <\/li>\n<\/ol>\n<ul>\n<li>Drawn numbers (swisslos_numbers) <\/li>\n<\/ul>\n<ol style=\"list-style-type: decimal\">\n<li>\n    type (normal, lucky, replay)\n  <\/li>\n<li>\n    number\n  <\/li>\n<li>\n    date\n  <\/li>\n<\/ol>\n<ul>\n<li>Payout per category correct (swisslos_payouts) <\/li>\n<\/ul>\n<ol style=\"list-style-type: decimal\">\n<li>\n    combination: normal + lucky (for example, 3 + 1 => three regular correct and lucky number correct)\n  <\/li>\n<li>\n    winners: number of winning tickets\n  <\/li>\n<li>\n    prize: payout (CHF) per winner\n  <\/li>\n<li>\n    date\n  <\/li>\n<\/ol>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># stringr::str_interp is a handy function to parameterize SQL queries from R\n# just be careful; SQL injections happen.\nshow_date &lt;- function(conn, table, date = \"2013-02-13\") {\n  dbGetQuery(conn, str_interp(\"SELECT * FROM ${table} WHERE date = &#39;${date}&#39;;\"))\n} \n\n#only show swisslos_ tables\nmap(keep(dbListTables(griddb), ~ str_detect(., \"swisslos_\")), ~ show_date(griddb, .))<\/code><\/pre>\n<\/div>\n<pre><code>## [[1]]\n##         date jackpot\n## 1 2013-02-13 8600000\n## \n## [[2]]\n##     type number       date\n## 1 normal     13 2013-02-13\n## 2 normal     21 2013-02-13\n## 3 normal     25 2013-02-13\n## 4 normal     26 2013-02-13\n## 5 normal     32 2013-02-13\n## 6 normal     40 2013-02-13\n## 7  lucky      1 2013-02-13\n## 8 replay     13 2013-02-13\n## \n## [[3]]\n##   combination winners   prize       date\n## 1       6 + 1       0    0.00 2013-02-13\n## 2           6       0    0.00 2013-02-13\n## 3       5 + 1       6 7570.15 2013-02-13\n## 4           5      36 1000.00 2013-02-13\n## 5       4 + 1     283  208.90 2013-02-13\n## 6           4    1690   87.35 2013-02-13\n## 7       3 + 1    4681   31.85 2013-02-13\n## 8           3   28264   10.55 2013-02-13\n<\/code><\/pre>\n<div id=\"swisslos-rules-and-probabilities\" class=\"section level2\">\n<h2>\n    Swisslos rules and probabilities<br \/>\n  <\/h2>\n<p> To play Swisslos, you choose six numbers between 1 and 42 and a single <\/p>\n<p>  <em>Lucky Number<\/em> between 1 and 6. <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\">regular_numbers &lt;- 42\nregular_draws   &lt;- 6\nlucky_numbers   &lt;- 6\nlucky_draws     &lt;- 1<\/code><\/pre>\n<\/p><\/div>\n<p> We can compute the number of possible combinations as follows. Of course, the <\/p>\n<p>  <em>Lucky Number<\/em> increases the number of combinations by a factor of six. <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># Binomial coefficient function\n# Bin(a, b)\nbin &lt;- function(a, b) {\n  map2_dbl(a, b, function(.a, .b) {\n    if (.b == 0 | .a == .b) {\n      1\n    } else {\n      .c &lt;- .a - .b + 1\n      prod(.c:.a) \/ prod(1:.b)\n    }\n  })\n}\n\n# 42 choose 6\nswisslos_regular_combos &lt;- bin(regular_numbers, regular_draws)<\/code><\/pre>\n<\/p><\/div>\n<p> There are 5245786 ways to choose six from 42, factoring in the <\/p>\n<p>  <em>Lucky Number<\/em> there are 31474716 combinations. Similarly, we can calculate the combinations of three, four, and five with or without the lucky number. So, we can calculate the probabilities. <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># probability to get n correct\nswisslos_prob &lt;- function(n) {\n  n_match &lt;- bin(regular_draws, n)\n  n_miss &lt;-  bin(regular_numbers - regular_draws, regular_draws - n)\n  n_miss * n_match  \/ swisslos_regular_combos\n} \n\n# We can check correctness with sum(swisslos_prob(0:6)) == 1, which yield true\n\ntibble(n_correct = 0:6) %&gt;% \n  mutate(\n    prob_base  = swisslos_prob(n_correct),\n    prob_lucky = prob_base \/ 6,\n    prob_not_lucky = prob_base - prob_lucky\n  ) %&gt;% \n  knitr::kable(digits = 8)<\/code><\/pre>\n<\/p><\/div>\n<style>\n    table {\n  border-spacing: 0;\n  width: 100%;\n  border: 1px solid #ddd;\n}<\/p>\n<p>th, td {\n  text-align: left;\n  padding: 16px;\n}<\/p>\n<p>tr:nth-child(even) {\n  background-color: #f2f2f2\n}\n  <\/style>\n<table>\n<thead>\n<tr class=\"header\">\n<th>\n          n_correct\n        <\/th>\n<th>\n          prob_base\n        <\/th>\n<th>\n          prob_lucky\n        <\/th>\n<th>\n          prob_not_lucky\n        <\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"odd\">\n<td>\n          0\n        <\/td>\n<td>\n          0.37130603\n        <\/td>\n<td>\n          0.06188434\n        <\/td>\n<td>\n          0.30942170\n        <\/td>\n<\/tr>\n<tr class=\"even\">\n<td>\n          1\n        <\/td>\n<td>\n          0.43119411\n        <\/td>\n<td>\n          0.07186568\n        <\/td>\n<td>\n          0.35932842\n        <\/td>\n<\/tr>\n<tr class=\"odd\">\n<td>\n          2\n        <\/td>\n<td>\n          0.16843520\n        <\/td>\n<td>\n          0.02807253\n        <\/td>\n<td>\n          0.14036266\n        <\/td>\n<\/tr>\n<tr class=\"even\">\n<td>\n          3\n        <\/td>\n<td>\n          0.02722185\n        <\/td>\n<td>\n          0.00453698\n        <\/td>\n<td>\n          0.02268488\n        <\/td>\n<\/tr>\n<tr class=\"odd\">\n<td>\n          4\n        <\/td>\n<td>\n          0.00180145\n        <\/td>\n<td>\n          0.00030024\n        <\/td>\n<td>\n          0.00150120\n        <\/td>\n<\/tr>\n<tr class=\"even\">\n<td>\n          5\n        <\/td>\n<td>\n          0.00004118\n        <\/td>\n<td>\n          0.00000686\n        <\/td>\n<td>\n          0.00003431\n        <\/td>\n<\/tr>\n<tr class=\"odd\">\n<td>\n          6\n        <\/td>\n<td>\n          0.00000019\n        <\/td>\n<td>\n          0.00000003\n        <\/td>\n<td>\n          0.00000016\n        <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> Note: It\u2019s more likely to get one right (~43%) than none (~37%). It\u2019s counter-intuitve and parallel to the <\/p>\n<p>  <a href=\"https:\/\/en.wikipedia.org\/wiki\/Birthday_problem\">birthday paradox<\/a>. <\/p>\n<h2>\n    Analysis<br \/>\n  <\/h2>\n<h3>\n    How many people play Swisslos every week?<br \/>\n  <\/h3>\n<p> Given that chance to get three out of six is 2.72%, we can estimate the number of people that play Swisslos (actually, we estimate the number of played tickets). <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># To retrieve the data from GridDB we type a SQL query\n# Computing the result with SQL makes it unnecessary to pull the entire table\n# into R\n\n# paste makes it easy to type long SQL and break it up into multiple lines\n\n# we make n a parameter because you could use 4 instead of 3 but 3 gets greater\n# counts so we will stick with that\nget_n_correct &lt;- function(conn, n) {\n  q &lt;- paste(\n    \"SELECT SUM(winners) AS winners, date\",\n    \"FROM swisslos_payouts\",\n    \"WHERE combination = &#39;${n}&#39;  OR combination = &#39;${n} + 1&#39;\",\n    \"GROUP BY date\",\n    \"ORDER BY date;\"\n  )\n  dbGetQuery(conn, str_interp(q))\n}\n  \nthree_correct &lt;- get_n_correct(griddb, 3) %&gt;% \n  mutate(tickets_played = winners \/ swisslos_prob(3)) %&gt;% \n  as_tibble()\n  \nthree_correct %&gt;% head(5)<\/code><\/pre>\n<\/p><\/div>\n<pre><code>## # A tibble: 5 \u00d7 3\n##   winners date       tickets_played\n##     &lt;dbl&gt; &lt;chr&gt;               &lt;dbl&gt;\n## 1   60705 2013-01-12       2230010.\n## 2   33745 2013-01-16       1239629.\n## 3   43457 2013-01-19       1596401.\n## 4   35013 2013-01-23       1286209.\n## 5   48120 2013-01-26       1767698.<\/code><\/pre>\n<\/div>\n<p>We can now plot the number of tickets that have been played overtime,<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\">three_correct %&gt;% \n  ggplot(aes(x = lubridate::as_date(date), y = tickets_played)) + \n  geom_col()<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2023\/02\/analysis-of-the-swisslos-lottery-using-r-and-griddb_image-1.png\" alt=\"\" \/><!-- --><\/p>\n<p>but maybe more interestingly, we can plot the number of tickets against the jackpot.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># You can test your SQL here, but because we need to get the entire \n# swisslos_jackpots table, we might just as well join it in R\nthree_correct_jp &lt;- three_correct %&gt;% \n  left_join(dbGetQuery(griddb, \"SELECT * FROM swisslos_jackpots;\"), by = \"date\")\n\nthree_correct_jp %&gt;% \n  ggplot(aes(x = tickets_played, y = jackpot)) +\n  geom_point()<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2023\/02\/analysis-of-the-swisslos-lottery-using-r-and-griddb_image-2.png\" alt=\"\" \/><!-- --><\/p>\n<p>We can clearly see a positive correlation between jackpot size and the number of tickets played.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\">cor.test(three_correct_jp$tickets_played, three_correct_jp$jackpot)<\/code><\/pre>\n<\/div>\n<pre><code>## \n##  Pearson&amp;#39;s product-moment correlation\n## \n## data:  three_correct_jp$tickets_played and three_correct_jp$jackpot\n## t = 33.147, df = 718, p-value &lt; 0.00000000000000022\n## alternative hypothesis: true correlation is not equal to 0\n## 95 percent confidence interval:\n##  0.7470597 0.8050008\n## sample estimates:\n##       cor \n## 0.7776764\n<\/code><\/pre>\n<p>(To answer this question in a simple manner, we assumed that people play their 6 out 42 completely randomly. They don\u2019t; but the effect should be small enough to not interfere with our ability to gauge the number of players.)<\/p>\n<h3>Which is the most frequently played Lucky Number?<\/h3>\n<p>To find the most frequently played<\/p>\n<p><em>Lucky Number<\/em>, we compare the counts of the winning combinations of three out of six without <em>Lucky Number<\/em> to the count of combinations that got the <em>Lucky Number<\/em> right. We can get the correct <em>Lucky Number<\/em> from our dataset, and so for each <em>Lucky Number<\/em> we now have a bunch of estimators, which we can show in a boxplot.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># Again, when writing straight SQL which is required for GridDB at the moment,\n# we want to make it as easy as possible for ourselves.\n# break SQL down into easy to understand snippets and combine\n# I think it&#39;s a good idea to avoid nested str_interp and only use them \n# for R computation\nget_n_lucky &lt;- function(conn, n) {\n  # Add lucky and regular winners for n\n  q_combined_counts &lt;- paste(\n    \"SELECT SUM(winners) AS winners, date\",\n    \"FROM swisslos_payouts\",\n    \"WHERE combination = &#39;${n}&#39; OR combination = &#39;${n} + 1&#39;\",\n    \"GROUP BY date\"\n  )\n  \n  # Only get lucky \n  q_lucky_counts &lt;- paste(\n    \"SELECT winners AS lucky, date\",\n    \"FROM swisslos_payouts\",\n    \"WHERE combination = &#39;${n} + 1&#39;\"\n  )\n  \n  # Combine lucky and regular counts\n  q_lucky_and_regular_counts &lt;- paste(\n    \"SELECT a.winners AS winners_count, b.lucky AS lucky_count, a.date AS date\",\n    \"FROM (\", q_combined_counts, \") a\",\n    \"LEFT JOIN (\", q_lucky_counts, \") b\",\n    \"ON a.date = b.date\",\n    \"ORDER BY a.date\"\n  )\n  \n  # Retrive lucky numbers\n  q_lucky_numbers &lt;- paste(\n    \"SELECT number AS lucky_number, date AS date\",\n    \"FROM swisslos_numbers\",\n    \"WHERE type = &#39;lucky&#39;\"\n  )\n\n  # Build the final query  \n  q_final &lt;- paste(\n    \"SELECT winners_count, lucky_count, lucky_number, c.date AS date\",\n    \"FROM (\", q_lucky_and_regular_counts, \") c\",\n    \"LEFT JOIN (\", q_lucky_numbers, \") d\",\n    \"ON c.date = d.date\"\n  )\n  \n  # Print the query if you want to know why building it up this way makes\n  # a lot of sense\n  \n  dbGetQuery(conn, str_interp(q_final))\n}\n\nlucky_counts &lt;- get_n_lucky(griddb, 3) %&gt;% \n  mutate(lucky_p = lucky_count \/ winners_count)\n\nhead(lucky_counts, n = 5)<\/code><\/pre>\n<\/div>\n<pre><code>##   winners_count lucky_count lucky_number       date   lucky_p\n## 1         60705        9174            4 2013-01-12 0.1511243\n## 2         33745        5005            4 2013-01-16 0.1483183\n## 3         43457        5810            6 2013-01-19 0.1336954\n## 4         35013        6326            2 2013-01-23 0.1806757\n## 5         48120       10718            3 2013-01-26 0.2227348\n<\/code><\/pre>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\">lucky_counts %&gt;% \n  ggplot(aes(x = factor(lucky_number), y = lucky_p, group = lucky_number)) + \n  geom_boxplot() +\n  geom_hline(yintercept = 1\/6)<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2023\/02\/analysis-of-the-swisslos-lottery-using-r-and-griddb_image-3.png\" alt=\"\" \/><!-- --><\/p>\n<p>Clearly, the Swiss love 3 and hate 1 for their <em>Lucky Number<\/em>.<\/p>\n<div id=\"which-are-the-most-frequently-played-standard-numbers\" class=\"section level3\">\n<h3>\n    Which are the most frequently played standard numbers?<br \/>\n  <\/h3>\n<p> This is a hard question. We\u2019ll show a fairly straight forward an hacky approach and invite you to devise a better way. Consider that the factor between the probabilities of four correct and three correct is 15.11. So, if in our data we find that the factor between the counts of four correct and three correct is greater, then the drawn numbers (on average) are slightly less likely to be played and if the factor is lesser then the played numbers are more likely to be played. <\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># We can do all of this directly on our GridDB\n# After we calculate the bias using the empirical frequencies and our\n# swisslos_prob function, we combine the table with the numbers table and\n# then we calculate the average bias for each number\nget_3_and_4 &lt;- function(conn) {\n  # Three correct\n  q_3 &lt;- paste(\n    \"SELECT SUM(winners) AS w_3, date\",\n    \"FROM swisslos_payouts\",\n    \"WHERE combination = &#39;3&#39; OR combination = &#39;3 + 1&#39;\",\n    \"GROUP BY date\"\n  )\n  \n  # Four correct\n  q_4 &lt;- paste(\n    \"SELECT SUM(winners) AS w_4, date\",\n    \"FROM swisslos_payouts\",\n    \"WHERE combination = &#39;4&#39; OR combination = &#39;4 + 1&#39;\",\n    \"GROUP BY date\"\n  )\n  \n  # Combine the three counts and four counts tables\n  q_w &lt;- paste(\n    \"SELECT w_3, w_4, c.date AS date\",\n    \"FROM (\", q_3, \") c\",\n    \"LEFT JOIN (\", q_4, \") d\",\n    \"ON c.date = d.date\"\n  )\n  \n  q_numbers &lt;- paste(\n    \"SELECT number, date\",\n    \"FROM swisslos_numbers\",\n    \"WHERE type = &#39;normal&#39;\"\n  )\n  \n  q_combine &lt;- paste(\n    \"SELECT w_3 \/ w_4 - ${swisslos_prob(3) \/ swisslos_prob(4)} AS bias,\",\n    \"number, a.date AS date\",\n    \"FROM (\", q_w, \") a\",\n    \"LEFT JOIN (\", q_numbers, \") b\",\n    \"ON a.date = b.date\"\n  )\n  \n  q_final &lt;- paste(\n    \"SELECT number, AVG(bias) AS bias\",\n    \"FROM (\", q_combine, \") e\",\n    \"GROUP BY number\"\n  )\n  \n  dbGetQuery(conn, str_interp(q_final))\n}\n\nhacky &lt;- get_3_and_4(griddb)\nhead(hacky)<\/code><\/pre>\n<\/p><\/div>\n<pre><code>##   number       bias\n## 1      1 -0.4834515\n## 2      2 -0.1532164\n## 3      3 -0.4042146\n## 4      4 -0.2777778\n## 5      5 -0.3198068\n## 6      6 -0.4269006<\/code><\/pre>\n<\/div>\n<p>So we can do a bit of hacky stuff, and then come up with this.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\"># Centering and negating bias to make it look prettier\nggplot(hacky, aes(x = factor(number), y = -(bias - mean(bias)), fill = -bias)) + geom_col() +\n  scale_fill_viridis_c() +\n  theme(legend.position = \"none\")<\/code><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2023\/02\/analysis-of-the-swisslos-lottery-using-r-and-griddb_image-4.png\" alt=\"\" \/><!-- --><\/p>\n<p>It\u2019s hard to say how accurate this is, but it makes sense. Numbers between 1 and 12, and 1 and 31 make birthdays. We can also see that 11, 22, and 33 are popular. So, which numbers should you play? None, because you\u2019ll lose money in the long run.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-r\">dbDisconnect(griddb)<\/code><\/pre>\n<\/div>\n<pre><code>## [1] TRUE\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that their chosen numbers will be drawn. Of course, unless the lottery is rigged, that is not the case. Most will realize that every number and every combination of numbers [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":29033,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Analysis of the Swisslos lottery using R and GridDB | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Analysis of the Swisslos lottery using R and GridDB | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-16T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:56:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1178\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"Analysis of the Swisslos lottery using R and GridDB\",\"datePublished\":\"2022-12-16T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:56:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\"},\"wordCount\":757,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\",\"name\":\"Analysis of the Swisslos lottery using R and GridDB | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg\",\"datePublished\":\"2022-12-16T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:56:24+00:00\",\"description\":\"A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg\",\"contentUrl\":\"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg\",\"width\":1920,\"height\":1178},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/griddb.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Analysis of the Swisslos lottery using R and GridDB | GridDB: Open Source Time Series Database for IoT","description":"A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","og_locale":"en_US","og_type":"article","og_title":"Analysis of the Swisslos lottery using R and GridDB | GridDB: Open Source Time Series Database for IoT","og_description":"A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that","og_url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2022-12-16T08:00:00+00:00","article_modified_time":"2025-11-13T20:56:24+00:00","og_image":[{"width":1920,"height":1178,"url":"https:\/\/griddb.net\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg","type":"image\/jpeg"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"Analysis of the Swisslos lottery using R and GridDB","datePublished":"2022-12-16T08:00:00+00:00","dateModified":"2025-11-13T20:56:24+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"},"wordCount":757,"commentCount":0,"publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","name":"Analysis of the Swisslos lottery using R and GridDB | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg","datePublished":"2022-12-16T08:00:00+00:00","dateModified":"2025-11-13T20:56:24+00:00","description":"A superstitious person may believe they are more likely to win the lottery by playing their lucky numbers. They believe there is a greater chance that","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/blog\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage","url":"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg","contentUrl":"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg","width":1920,"height":1178},{"@type":"WebSite","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/griddb.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46740"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46740\/revisions"}],"predecessor-version":[{"id":51410,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46740\/revisions\/51410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media\/29033"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}