{"id":2991,"date":"2023-07-19T18:16:07","date_gmt":"2023-07-19T18:16:07","guid":{"rendered":"https:\/\/statorials.org\/nl\/runif-in-r\/"},"modified":"2023-07-19T18:16:07","modified_gmt":"2023-07-19T18:16:07","slug":"runif-in-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/runif-in-r\/","title":{"rendered":"Hoe de runif-functie in r te gebruiken (4 voorbeelden)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Je kunt de functie <strong>runif()<\/strong> gebruiken om willekeurige waarden te genereren uit een <a href=\"https:\/\/statorials.org\/nl\/uniforme-verdeling\/\" target=\"_blank\" rel=\"noopener\">uniforme verdeling<\/a> in R.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Deze functie gebruikt de volgende syntaxis:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>runif(n, min= <span style=\"color: #008000;\">0<\/span> , max= <span style=\"color: #008000;\">1<\/span> )\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Goud:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>n<\/strong> : Het aantal willekeurige waarden dat moet worden gegenereerd<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>min<\/strong> : de minimumwaarde van de verdeling (standaard is 0)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>max<\/strong> : De maximale waarde van de verdeling (standaard is 1)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">De volgende voorbeelden laten zien hoe u de functie <strong>runif()<\/strong> in verschillende scenario&#8217;s kunt gebruiken.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Voorbeeld 1: Gebruik runif() om willekeurige waarden te genereren<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">De volgende code laat zien hoe je de functie <strong>runif()<\/strong> gebruikt om 10 willekeurige waarden te genereren uit een uniforme verdeling tussen 50 en 100:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#make this example reproducible\n<span style=\"color: #000000;\">set. <span style=\"color: #3366ff;\">seeds<\/span> (5)\n<\/span>\n#generate 10 random values from uniform distribution\n<span style=\"color: #000000;\">runif(n= <span style=\"color: #008000;\">10<\/span> , min= <span style=\"color: #008000;\">50<\/span> , max= <span style=\"color: #008000;\">100<\/span> )\n\n[1] 60.01072 84.26093 95.84379 64.21997 55.23251 85.05287 76.39800 90.39676\n[9] 97.82501 55.52265\n<\/span><\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat elk van de 10 gegenereerde willekeurige waarden tussen 50 en 100 ligt.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Voorbeeld 2: Gebruik runif() om willekeurige waarden te genereren, afgerond op decimalen<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe je de functie <strong>round()<\/strong> kunt gebruiken met de functie <strong>runif()<\/strong> om 10 willekeurige waarden te genereren uit een uniforme verdeling vari\u00ebrend van 50 tot 100, waarbij elke waarde wordt afgerond op \u00e9\u00e9n decimaal:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (5)\n\n<span style=\"color: #008080;\">#generate 10 random values from uniform distribution rounded to one decimal place\n<\/span>round(runif(n= <span style=\"color: #008000;\">10<\/span> , min= <span style=\"color: #008000;\">50<\/span> , max= <span style=\"color: #008000;\">100<\/span> ), 1)\n\n[1] 63.7 74.5 65.9 78.0 63.1 60.1 69.4 94.4 77.7 92.1\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Houd er rekening mee dat elk van de 10 gegenereerde willekeurige waarden tussen 50 en 100 ligt en wordt afgerond op \u00e9\u00e9n decimaal.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Voorbeeld 3: Gebruik runif() om willekeurige waarden te genereren, afgerond op gehele getallen<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe je de functie <strong>round()<\/strong> kunt gebruiken met de functie <strong>runif()<\/strong> om 10 willekeurige waarden te genereren uit een uniforme verdeling vari\u00ebrend van 50 tot 100, waarbij elke waarde wordt afgerond op een geheel getal:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (5)\n\n<span style=\"color: #008080;\">#generate 10 random values from uniform distribution rounded to whole number\n<\/span>round(runif(n= <span style=\"color: #008000;\">10<\/span> , min= <span style=\"color: #008000;\">50<\/span> , max= <span style=\"color: #008000;\">100<\/span> ), 0)\n\n[1] 64 75 66 78 63 60 69 94 78 92\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Merk op dat elk van de 10 gegenereerde willekeurige waarden tussen 50 en 100 ligt en wordt afgerond op een geheel getal.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Voorbeeld 4: Gebruik runif() om een uniform distributiehistogram te maken<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u de functie <strong>runif()<\/strong> gebruikt om 1000 willekeurige waarden te genereren uit een uniforme verdeling vari\u00ebrend van 50 tot 100, en vervolgens de functie <strong>hist()<\/strong> te gebruiken om een histogram te maken dat deze verdeling van waarden visualiseert.<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#make this example reproducible\n<\/span>set. <span style=\"color: #3366ff;\">seeds<\/span> (5)\n\n<span style=\"color: #008080;\">#generate 1,000 random values from uniform distribution\n<\/span>values &lt;- runif(n= <span style=\"color: #008000;\">1000<\/span> , min= <span style=\"color: #008000;\">50<\/span> , max= <span style=\"color: #008000;\">100<\/span> )\n\n<span style=\"color: #008080;\">#generate histogram to visualize these values<\/span>\nhist(values)<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-25838\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/runif1-1.jpg\" alt=\"runief histogram in R\" width=\"446\" height=\"449\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Het resultaat is een histogram dat de verdeling weergeeft van de 1000 waarden die zijn gegenereerd op basis van de uniforme verdeling.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende taken in R kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/teken-een-uniforme-verdeling-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe een uniforme verdeling in R te plotten<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/willekeurige-steekproef-in-r\/\" target=\"_blank\" rel=\"noopener\">Hoe willekeurige steekproeven te selecteren in R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Je kunt de functie runif() gebruiken om willekeurige waarden te genereren uit een uniforme verdeling in R. Deze functie gebruikt de volgende syntaxis: runif(n, min= 0 , max= 1 ) Goud: n : Het aantal willekeurige waarden dat moet worden gegenereerd min : de minimumwaarde van de verdeling (standaard is 0) max : De maximale [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-2991","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe de runif-functie in R te gebruiken (4 voorbeelden) \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie runif() in R kunt gebruiken om willekeurige waarden uit de uniforme verdeling te genereren.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/nl\/runif-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe de runif-functie in R te gebruiken (4 voorbeelden) \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie runif() in R kunt gebruiken om willekeurige waarden uit de uniforme verdeling te genereren.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/runif-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-19T18:16:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/runif1-1.jpg\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/runif-in-r\/\",\"url\":\"https:\/\/statorials.org\/nl\/runif-in-r\/\",\"name\":\"Hoe de runif-functie in R te gebruiken (4 voorbeelden) \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-19T18:16:07+00:00\",\"dateModified\":\"2023-07-19T18:16:07+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de functie runif() in R kunt gebruiken om willekeurige waarden uit de uniforme verdeling te genereren.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/runif-in-r\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/runif-in-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/runif-in-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe de runif-functie in r te gebruiken (4 voorbeelden)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe de runif-functie in R te gebruiken (4 voorbeelden) \u2013 Statorials","description":"In deze tutorial wordt uitgelegd hoe u de functie runif() in R kunt gebruiken om willekeurige waarden uit de uniforme verdeling te genereren.","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:\/\/statorials.org\/nl\/runif-in-r\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe de runif-functie in R te gebruiken (4 voorbeelden) \u2013 Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de functie runif() in R kunt gebruiken om willekeurige waarden uit de uniforme verdeling te genereren.","og_url":"https:\/\/statorials.org\/nl\/runif-in-r\/","og_site_name":"Statorials","article_published_time":"2023-07-19T18:16:07+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/runif1-1.jpg"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/runif-in-r\/","url":"https:\/\/statorials.org\/nl\/runif-in-r\/","name":"Hoe de runif-functie in R te gebruiken (4 voorbeelden) \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-19T18:16:07+00:00","dateModified":"2023-07-19T18:16:07+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de functie runif() in R kunt gebruiken om willekeurige waarden uit de uniforme verdeling te genereren.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/runif-in-r\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/runif-in-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/runif-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe de runif-functie in r te gebruiken (4 voorbeelden)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=2991"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2991\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=2991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=2991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=2991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}