{"id":50835,"date":"2022-12-16T00:00:00","date_gmt":"2022-12-16T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"},"modified":"2025-11-14T07:55:53","modified_gmt":"2025-11-14T15:55:53","slug":"analysis-of-the-swisslos-lottery-using-r-and-griddb","status":"publish","type":"post","link":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","title":{"rendered":"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790"},"content":{"rendered":"<p>\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3001\u5b9d\u304f\u3058\u304c\u4e0d\u6b63\u306b\u64cd\u4f5c\u3055\u308c\u3066\u3044\u306a\u3044\u9650\u308a\u3001\u305d\u306e\u3088\u3046\u306a\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u307b\u3068\u3093\u3069\u306e\u4eba\u306f\u3001\u3069\u306e\u6570\u5b57\u3082\u3001\u3069\u306e\u6570\u5b57\u306e\u7d44\u307f\u5408\u308f\u305b\u3082\u3001\u540c\u3058\u53ef\u80fd\u6027\u3092\u6301\u3063\u3066\u3044\u308b\u3053\u3068\u306b\u6c17\u304c\u3064\u304f\u3067\u3057\u3087\u3046\u3002\u3057\u304b\u3057\u3001\u3053\u3053\u304c\u9762\u767d\u3044\u3068\u3053\u308d\u3067\u3059\u304c\u3001\u3059\u3079\u3066\u306e\u7d44\u307f\u5408\u308f\u305b\u304c\u540c\u3058\u671f\u5f85\u5024\u3092\u6301\u3063\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u79c1\u305f\u3061\u306e\u8003\u3048\u306f\u3053\u3046\u3067\u3059\u3002\u8ff7\u4fe1\u6df1\u3044\u4eba\u3082\u3044\u307e\u3059\u3057\u3001\u4eba\u9593\u306f\u30e9\u30f3\u30c0\u30e0\u306b\u6570\u5b57\u3092\u9078\u3076\u306e\u304c\u82e6\u624b\u306a\u306e\u3067\u3001\u30ae\u30e3\u30f3\u30d6\u30e9\u30fc\u304c\u4ed6\u306e\u6570\u5b57\u3088\u308a\u305a\u3063\u3068\u983b\u7e41\u306b\u30d7\u30ec\u30a4\u3059\u308b\u6570\u5b57\u304c\u3042\u308a\u307e\u3059\u3002\u4ed6\u306e\u4eba\u304c\u30d7\u30ec\u30a4\u3059\u308b\u53ef\u80fd\u6027\u304c\u6700\u3082\u4f4e\u3044\u6570\u5b57\u3092\u30d7\u30ec\u30a4\u3067\u304d\u308c\u3070\u3001\u5b9f\u969b\u306b\u52dd\u3063\u305f\u5834\u5408\u3001\u3088\u308a\u5c11\u306a\u3044\u4eba\u6570\u3067\u30dd\u30c3\u30c8\u3092\u5206\u3051\u3089\u308c\u308b\u306e\u3067\u3001\u3088\u308a\u591a\u304f\u306e\u304a\u91d1\u3092\u7372\u5f97\u3067\u304d\u308b\u3053\u3068\u304c\u671f\u5f85\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u3067\u3059\u304b\u3089\u3001\u9577\u671f\u7684\u306b\u898b\u308c\u3070\u3001\u3088\u308a\u591a\u304f\u306e\u304a\u91d1\u3092\u7a3c\u3050\u3053\u3068\u304c\u3067\u304d\u308b\u6570\u5b57\u304c\u3042\u308b\u3053\u3068\u306f\u4e8b\u5b9f\u3067\u3059\u3002\u3088\u308a\u591a\u304f\u306e\u304a\u91d1\u3092\u7a3c\u3050\u3068\u3044\u3046\u306e\u306f\u3001\u5e73\u5747\u7684\u306a\u5b9d\u304f\u3058\u30d7\u30ec\u30a4\u30e4\u30fc\u3088\u308a\u3082\u9045\u3044\u901f\u5ea6\u3067\u304a\u91d1\u3092\u5931\u3046\u3068\u3044\u3046\u610f\u5473\u3067\u3001\u305d\u308c\u3067\u3082\u304a\u91d1\u3092\u5931\u3046\u3053\u3068\u306b\u5909\u308f\u308a\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u5168\u6587\u306f\u3053\u3061\u3089\u3067\u3054\u89a7\u3044\u305f\u3060\u3051\u307e\u3059\u3002<a href=\"https:\/\/github.com\/retowyss\/swisslos-r-griddb\/\">https:\/\/github.com\/retowyss\/swisslos-r-griddb\/<\/a><\/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>\u30c7\u30fc\u30bf\u306e\u6982\u8981\u3068\u5206\u6790\u30c4\u30fc\u30eb<\/h2>\n<p>\u30b9\u30a4\u30b9\u306e\u56fd\u55b6\u5b9d\u304f\u3058\u300cSwisslos\u300d\u306e\u7d047\u5e74\u5206\u306e\u62bd\u9078\u7d50\u679c\uff08n = 720, start = 2013-01-12, end = 2019-12-04\uff09\u3092\u3001\u7d71\u8a08\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9eR\u3092\u7528\u3044\u3066\u5206\u6790\u3057\u3001\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u306b\u306fGridDB\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/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>\n<p>\u30b8\u30e3\u30c3\u30af\u30dd\u30c3\u30c8\u306e\u30b5\u30a4\u30ba (swisslos_jackpots)<\/p>\n<ol>\n<li>\u65e5\u4ed8<\/li>\n<li>\u30b8\u30e3\u30c3\u30af\u30dd\u30c3\u30c8\uff1a6\uff0b1\u306e\u6700\u5927\u652f\u6255\u3044\u984d (CHF)<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u63cf\u753b\u3055\u308c\u305f\u6570\u5b57 (swisslos_numbers)<\/p>\n<ol>\n<li>\u7a2e\u985e (normal, lucky, replay)<\/li>\n<li>\u756a\u53f7<\/li>\n<li>\u65e5\u4ed8<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\u6b63\u89e3\u3057\u305f\u30ab\u30c6\u30b4\u30ea\u3054\u3068\u306e\u30da\u30a4\u30a2\u30a6\u30c8 (swisslos_payouts)<\/p>\n<ol>\n<li>\u7d44\u307f\u5408\u308f\u305b\uff1a\u30ce\u30fc\u30de\u30eb\uff0b\u30e9\u30c3\u30ad\u30fc (\u4f8b\uff1a3\uff0b1\u21d23\u3064\u306e\u30ec\u30ae\u30e5\u30e9\u30fc\u6b63\u89e3\u30681\u3064\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u6b63\u89e3)<\/li>\n<li>\u5f53\u9078\u8005\u6570\uff1a\u5f53\u9078\u3057\u305f\u30c1\u30b1\u30c3\u30c8\u306e\u679a\u6570<\/li>\n<li>\u8cde\u91d1\uff1a\u5f53\u9078\u8005\u4e00\u4eba\u3042\u305f\u308a\u306e\u652f\u6255\u3044\u984d (CHF)<\/li>\n<li>\u65e5\u4ed8<\/li>\n<\/ol>\n<\/li>\n<\/ul>\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<h2>\u30b9\u30a4\u30b9\u306e\u30eb\u30fc\u30eb\u3068\u78ba\u7387<\/h2>\n<p>Swisslos\u3092\u30d7\u30ec\u30a4\u3059\u308b\u306b\u306f\u30011\u301c42\u306e6\u3064\u306e\u6570\u5b57\u3068\u30011\u301c6\u306e <em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u30921\u3064\u9078\u3073\u307e\u3059\u3002<\/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<\/div>\n<p>\u53ef\u80fd\u306a\u7d44\u307f\u5408\u308f\u305b\u306e\u6570\u306f\u3001\u6b21\u306e\u3088\u3046\u306b\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002 \u3082\u3061\u308d\u3093 <em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u306f\u3001\u7d44\u307f\u5408\u308f\u305b\u306e\u6570\u30926\u500d\u306b\u5897\u3084\u3057\u307e\u3059\u3002<\/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<\/div>\n<p>42\u304b\u30896\u3092\u9078\u3076\u65b9\u6cd5\u306f5245786\u901a\u308a\u3042\u308a\u3001<em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u3092\u52a0\u3048\u308b\u306831474716\u901a\u308a\u306e\u7d44\u307f\u5408\u308f\u305b\u304c\u3042\u308a\u307e\u3059\u3002\u540c\u69d8\u306b 3, 4, 5 \u306e\u7d44\u307f\u5408\u308f\u305b\u3082\u3001\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u306e\u6709\u7121\u306b\u304b\u304b\u308f\u3089\u305a\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u78ba\u7387\u3092\u8a08\u7b97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/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<\/div>\n<p><style>\n  table {\n  border-spacing: 0;\n  width: 100%;\n  border: 1px solid #ddd;\n}\n<\/style>\n<\/p>\n<p>th, td { text-align: left; padding: 16px; }<\/p>\n<p>tr:nth-child(even) { background-color: #f2f2f2 }<\/p>\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>\u6ce8\uff1a1\u3064\u3082\u5f53\u305f\u3089\u306a\u3044\uff08\uff5e37\uff05\uff09\u3088\u308a\u30011\u3064\u5f53\u305f\u308b\uff08\uff5e43\uff05\uff09\u306e\u65b9\u304c\u78ba\u7387\u304c\u9ad8\u3044\u3002\u3053\u308c\u306f\u3068<a href=\"https:\/\/en.wikipedia.org\/wiki\/Birthday_problem\">\u8a95\u751f\u65e5\u306e\u30d1\u30e9\u30c9\u30c3\u30af\u30b9<\/a>\u3068\u540c\u69d8\u306b\u76f4\u89b3\u306b\u53cd\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<h2>\u5206\u6790<\/h2>\n<h3>\u30b9\u30a4\u30b9\u3067\u306f\u3001\u6bce\u9031\u3069\u308c\u304f\u3089\u3044\u306e\u4eba\u304c\u30d7\u30ec\u30a4\u3092\u3057\u3066\u3044\u308b\u306e\u3067\u3057\u3087\u3046\u304b\uff1f<\/h3>\n<p>6\u679a\u306e\u3046\u30613\u679a\u304c\u5f53\u305f\u308b\u78ba\u7387\u304c2.72%\u3067\u3042\u308b\u3053\u3068\u304b\u3089\u3001\u30b9\u30a4\u30b9\u3067\u30d7\u30ec\u30a4\u3059\u308b\u4eba\u306e\u6570\u3092\u63a8\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u5b9f\u969b\u306b\u306f\u3001\u30d7\u30ec\u30a4\u3055\u308c\u305f\u30c1\u30b1\u30c3\u30c8\u306e\u6570\u3092\u63a8\u5b9a\u3057\u307e\u3059\uff09<\/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<\/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.\n<\/code><\/pre>\n<p>\u3053\u308c\u3067\u3001\u5ef6\u9577\u6226\u306b\u306a\u3063\u305f\u30c1\u30b1\u30c3\u30c8\u306e\u679a\u6570\u3092\u30d7\u30ed\u30c3\u30c8\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/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>\u3057\u304b\u3057\u3001\u3082\u3063\u3068\u9762\u767d\u3044\u306e\u306f\u3001\u30b8\u30e3\u30c3\u30af\u30dd\u30c3\u30c8\u306b\u5bfe\u3059\u308b\u30c1\u30b1\u30c3\u30c8\u306e\u679a\u6570\u3092\u30d7\u30ed\u30c3\u30c8\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3053\u3068\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/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>\u30b8\u30e3\u30c3\u30af\u30dd\u30c3\u30c8\u306e\u30b5\u30a4\u30ba\u3068\u30d7\u30ec\u30a4\u679a\u6570\u306b\u306f\u3001\u660e\u3089\u304b\u306b\u6b63\u306e\u76f8\u95a2\u304c\u3042\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/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>(\u3053\u306e\u8cea\u554f\u306b\u7c21\u5358\u306b\u7b54\u3048\u308b\u305f\u3081\u306b\u3001\u79c1\u305f\u3061\u306f\u3001\u4eba\u3005\u304c42\u5206\u306e6\u3092\u5b8c\u5168\u306b\u30e9\u30f3\u30c0\u30e0\u306b\u30d7\u30ec\u30a4\u3057\u3066\u3044\u308b\u3068\u4eee\u5b9a\u3057\u307e\u3057\u305f\u3002\u3057\u304b\u3057\u3001\u305d\u306e\u52b9\u679c\u306f\u3001\u30d7\u30ec\u30a4\u30e4\u30fc\u306e\u6570\u3092\u6e2c\u5b9a\u3059\u308b\u80fd\u529b\u3092\u59a8\u3052\u306a\u3044\u7a0b\u5ea6\u306b\u5c0f\u3055\u3044\u306f\u305a\u3067\u3059\u3002)<\/p>\n<h3>\u6700\u3082\u983b\u7e41\u306b\u518d\u751f\u3055\u308c\u308b\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u306f\u3069\u308c\u3067\u3059\u304b\uff1f<\/h3>\n<p>\u6700\u3082\u983b\u7e41\u306b\u518d\u751f\u3055\u308c\u308b\u3082\u306e\u3092\u63a2\u3059\u306b\u306f<\/p>\n<p><em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u306e\u306a\u30446\u3064\u306e\u7d44\u5408\u305b\u306e\u3046\u3061\u30013\u3064\u306e\u7d44\u5408\u305b\u306e\u5f53\u9078\u56de\u6570\u3092 <em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u304c\u5f53\u305f\u3063\u305f\u7d44\u5408\u305b\u306e\u56de\u6570\u3068\u6bd4\u8f03\u3057\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u304b\u3089\u6b63\u3057\u3044 <em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u304c\u5f97\u3089\u308c\u308b\u306e\u3067\u3001\u5404 <em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u306b\u3064\u3044\u3066\u3001\u305f\u304f\u3055\u3093\u306e\u63a8\u5b9a\u91cf\u304c\u5f97\u3089\u308c\u3001\u30dc\u30c3\u30af\u30b9\u30d7\u30ed\u30c3\u30c8\u3067\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/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>\u30b9\u30a4\u30b9\u4eba\u306f <em>\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc<\/em> \u3068\u3057\u3066 3 \u3092\u597d\u307f\u30011 \u3092\u5acc\u3046\u306e\u306f\u660e\u3089\u304b\u3067\u3059\u3002<\/p>\n<h3>\u6700\u3082\u983b\u7e41\u306b\u518d\u751f\u3055\u308c\u308b\u30b9\u30bf\u30f3\u30c0\u30fc\u30c9\u30ca\u30f3\u30d0\u30fc\u306f\u3069\u308c\u3067\u3059\u304b\uff1f<\/h3>\n<p>\u3053\u308c\u306f\u96e3\u3057\u3044\u554f\u984c\u3067\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u304b\u306a\u308a\u76f4\u7403\u3067\u30cf\u30c1\u30e3\u30e1\u30c1\u30e3\u306a\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u306e\u3067\u3001\u3088\u308a\u826f\u3044\u65b9\u6cd5\u3092\u8003\u6848\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u6b63\u89e3\u65704\u3068\u6b63\u89e3\u65703\u306e\u78ba\u7387\u306e\u9593\u306e\u4fc2\u6570\u304c15.11\u3067\u3042\u308b\u3053\u3068\u3092\u8003\u3048\u307e\u3057\u3087\u3046\u3002\u305d\u3053\u3067\u3001\u3082\u3057\u3001\u30c7\u30fc\u30bf\u306e\u4e2d\u3067\u30014\u3064\u306e\u6b63\u89e3\u6570\u30683\u3064\u306e\u6b63\u89e3\u6570\u306e\u9593\u306e\u4fc2\u6570\u304c\u5927\u304d\u3051\u308c\u3070\u3001\uff08\u5e73\u5747\u3057\u3066\uff09\u5f15\u3044\u305f\u6570\u5b57\u306f\u5f3e\u304b\u308c\u308b\u53ef\u80fd\u6027\u304c\u5c11\u3057\u4f4e\u304f\u3001\u4fc2\u6570\u304c\u5c0f\u3055\u3051\u308c\u3070\u3001\u5f3e\u304b\u308c\u305f\u6570\u5b57\u306f\u5f3e\u304b\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u8003\u3048\u3089\u308c\u307e\u3059\u3002<\/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<\/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\n<\/code><\/pre>\n<p>\u305d\u3053\u3067\u3001\u3061\u3087\u3063\u3068\u30cf\u30c1\u30e3\u30e1\u30c1\u30e3\u306a\u3053\u3068\u3092\u3057\u3066\u3001\u3053\u3093\u306a\u3053\u3068\u3092\u601d\u3044\u3064\u304f\u306e\u3067\u3059\u3002<\/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>\u3053\u308c\u304c\u3069\u308c\u3060\u3051\u6b63\u78ba\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u3001\u7406\u306b\u304b\u306a\u3063\u3066\u3044\u307e\u3059\u30021\u304b\u308912\u307e\u3067\u30011\u304b\u308931\u307e\u3067\u306e\u6570\u5b57\u304c\u8a95\u751f\u65e5\u306b\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u300111\u300122\u300133\u3082\u4eba\u6c17\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002\u3067\u306f\u3001\u3069\u306e\u6570\u5b57\u3092\u30d7\u30ec\u30a4\u3059\u308c\u3070\u3044\u3044\u306e\u3067\u3057\u3087\u3046\u304b\uff1f\u3069\u308c\u3082\u3001\u9577\u3044\u76ee\u3067\u898b\u308c\u3070\u640d\u3092\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u304b\u3089\u3067\u3059\u3002<\/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>\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u3067\u3059\u3002 \u3082\u3061\u308d\u3093\u3001\u5b9d\u304f\u3058\u304c\u4e0d\u6b63\u306b\u64cd\u4f5c\u3055\u308c\u3066\u3044\u306a\u3044\u9650\u308a\u3001\u305d\u306e [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":49507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1005],"tags":[],"class_list":["post-50835","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1005"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790 | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\" \/>\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.net\/ja\/\u672a\u5206\u985e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790 | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/ja\/\u672a\u5206\u985e\/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-14T15:55:53+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=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"6\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/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\":\"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790\",\"datePublished\":\"2022-12-16T08:00:00+00:00\",\"dateModified\":\"2025-11-14T15:55:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\"},\"wordCount\":52,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg\",\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\",\"url\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\",\"name\":\"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790 | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/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-14T15:55:53+00:00\",\"description\":\"\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\",\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/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\":\"ja\"},{\"@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\":\"ja\",\"@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\":\"ja\",\"@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\/ja\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790 | GridDB: Open Source Time Series Database for IoT","description":"\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b","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.net\/ja\/\u672a\u5206\u985e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","og_locale":"ja_JP","og_type":"article","og_title":"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790 | GridDB: Open Source Time Series Database for IoT","og_description":"\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b","og_url":"https:\/\/griddb.net\/ja\/\u672a\u5206\u985e\/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-14T15:55:53+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":{"\u57f7\u7b46\u8005":"griddb-admin","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"6\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/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":"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790","datePublished":"2022-12-16T08:00:00+00:00","dateModified":"2025-11-14T15:55:53+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"},"wordCount":52,"commentCount":0,"publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/12\/bingo_1920x1178.jpg","inLanguage":"ja","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","url":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/","name":"R \u3068 GridDB \u3092\u7528\u3044\u305f Swisslos (\u30b9\u30a4\u30b9\u30ed\u30c8) \u306e\u89e3\u6790 | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/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-14T15:55:53+00:00","description":"\u8ff7\u4fe1\u6df1\u3044\u4eba\u306f\u3001\u81ea\u5206\u306e\u30e9\u30c3\u30ad\u30fc\u30ca\u30f3\u30d0\u30fc\u3067\u52dd\u8ca0\u3057\u305f\u307b\u3046\u304c\u5b9d\u304f\u3058\u306b\u5f53\u305f\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u81ea\u5206\u306e\u9078\u3093\u3060\u6570\u5b57\u304c\u62bd\u9078\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u9ad8\u3044\u3068\u4fe1\u3058\u3066\u3044\u308b","inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/analysis-of-the-swisslos-lottery-using-r-and-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/griddb.net\/ja\/%e6%9c%aa%e5%88%86%e9%a1%9e\/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":"ja"},{"@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":"ja","@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":"ja","@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\/ja\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/posts\/50835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/comments?post=50835"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/posts\/50835\/revisions"}],"predecessor-version":[{"id":51663,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/posts\/50835\/revisions\/51663"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/media\/49507"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/media?parent=50835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/categories?post=50835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/ja\/wp-json\/wp\/v2\/tags?post=50835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}