{"id":2990,"date":"2023-07-19T18:16:07","date_gmt":"2023-07-19T18:16:07","guid":{"rendered":"https:\/\/statorials.org\/pt\/runif-em-r\/"},"modified":"2023-07-19T18:16:07","modified_gmt":"2023-07-19T18:16:07","slug":"runif-em-r","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/runif-em-r\/","title":{"rendered":"Como usar a fun\u00e7\u00e3o runif em r (4 exemplos)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Voc\u00ea pode usar a fun\u00e7\u00e3o <strong>runif()<\/strong> para gerar valores aleat\u00f3rios a partir de uma <a href=\"https:\/\/statorials.org\/pt\/distribuicao-uniforme\/\" target=\"_blank\" rel=\"noopener\">distribui\u00e7\u00e3o uniforme<\/a> em R.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Esta fun\u00e7\u00e3o usa a seguinte sintaxe:<\/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;\">Ouro:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>n<\/strong> : O n\u00famero de valores aleat\u00f3rios a serem gerados<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>min<\/strong> : O valor m\u00ednimo da distribui\u00e7\u00e3o (o padr\u00e3o \u00e9 0)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>max<\/strong> : O valor m\u00e1ximo da distribui\u00e7\u00e3o (o padr\u00e3o \u00e9 1)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Os exemplos a seguir mostram como usar a fun\u00e7\u00e3o <strong>runif()<\/strong> em diferentes cen\u00e1rios.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 1: Use runif() para gerar valores aleat\u00f3rios<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar a fun\u00e7\u00e3o <strong>runif()<\/strong> para gerar 10 valores aleat\u00f3rios a partir de uma distribui\u00e7\u00e3o uniforme entre 50 e 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;\">Observe que cada um dos 10 valores aleat\u00f3rios gerados est\u00e1 entre 50 e 100.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 2: Use runif() para gerar valores aleat\u00f3rios arredondados para casas decimais<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar a fun\u00e7\u00e3o <strong>round()<\/strong> com a fun\u00e7\u00e3o <strong>runif()<\/strong> para gerar 10 valores aleat\u00f3rios a partir de uma distribui\u00e7\u00e3o uniforme variando de 50 a 100, em que cada valor \u00e9 arredondado para uma casa decimal:<\/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;\">Observe que cada um dos 10 valores aleat\u00f3rios gerados est\u00e1 entre 50 e 100 e \u00e9 arredondado para uma casa decimal.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 3: Use runif() para gerar valores aleat\u00f3rios arredondados para inteiros<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar a fun\u00e7\u00e3o <strong>round()<\/strong> com a fun\u00e7\u00e3o <strong>runif()<\/strong> para gerar 10 valores aleat\u00f3rios a partir de uma distribui\u00e7\u00e3o uniforme variando de 50 a 100, em que cada valor \u00e9 arredondado para um n\u00famero inteiro:<\/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;\">Observe que cada um dos 10 valores aleat\u00f3rios gerados est\u00e1 entre 50 e 100 e \u00e9 arredondado para um n\u00famero inteiro.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Exemplo 4: Use runif() para criar um histograma de distribui\u00e7\u00e3o uniforme<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">O c\u00f3digo a seguir mostra como usar a fun\u00e7\u00e3o <strong>runif()<\/strong> para gerar 1.000 valores aleat\u00f3rios a partir de uma distribui\u00e7\u00e3o uniforme variando de 50 a 100 e, em seguida, usar a fun\u00e7\u00e3o <strong>hist()<\/strong> para criar um histograma que visualize essa distribui\u00e7\u00e3o de valores.<\/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=\"histograma runivo em R\" width=\"446\" height=\"449\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">O resultado \u00e9 um histograma que exibe a distribui\u00e7\u00e3o dos 1.000 valores gerados a partir da distribui\u00e7\u00e3o uniforme.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Os tutoriais a seguir explicam como realizar outras tarefas comuns em R:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/pt\/tracar-uma-distribuicao-uniforme-em-r\/\" target=\"_blank\" rel=\"noopener\">Como tra\u00e7ar uma distribui\u00e7\u00e3o uniforme em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/amostra-aleatoria-em-r\/\" target=\"_blank\" rel=\"noopener\">Como selecionar amostras aleat\u00f3rias em R<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voc\u00ea pode usar a fun\u00e7\u00e3o runif() para gerar valores aleat\u00f3rios a partir de uma distribui\u00e7\u00e3o uniforme em R. Esta fun\u00e7\u00e3o usa a seguinte sintaxe: runif(n, min= 0 , max= 1 ) Ouro: n : O n\u00famero de valores aleat\u00f3rios a serem gerados min : O valor m\u00ednimo da distribui\u00e7\u00e3o (o padr\u00e3o \u00e9 0) max : [&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-2990","post","type-post","status-publish","format-standard","hentry","category-guia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Como usar a fun\u00e7\u00e3o runif em R (4 exemplos) \u2013 Estatologia<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o runif() em R para gerar valores aleat\u00f3rios a partir da distribui\u00e7\u00e3o uniforme.\" \/>\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\/pt\/runif-em-r\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como usar a fun\u00e7\u00e3o runif em R (4 exemplos) \u2013 Estatologia\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como usar a fun\u00e7\u00e3o runif() em R para gerar valores aleat\u00f3rios a partir da distribui\u00e7\u00e3o uniforme.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/runif-em-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. benjamim anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. benjamim anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/runif-em-r\/\",\"url\":\"https:\/\/statorials.org\/pt\/runif-em-r\/\",\"name\":\"Como usar a fun\u00e7\u00e3o runif em R (4 exemplos) \u2013 Estatologia\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-19T18:16:07+00:00\",\"dateModified\":\"2023-07-19T18:16:07+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como usar a fun\u00e7\u00e3o runif() em R para gerar valores aleat\u00f3rios a partir da distribui\u00e7\u00e3o uniforme.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/runif-em-r\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/runif-em-r\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/runif-em-r\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como usar a fun\u00e7\u00e3o runif em r (4 exemplos)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pt\/#website\",\"url\":\"https:\/\/statorials.org\/pt\/\",\"name\":\"Statorials\",\"description\":\"O seu guia para a literacia estat\u00edstica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pt\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\",\"name\":\"Dr. benjamim anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. benjamim anderson\"},\"description\":\"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais\",\"sameAs\":[\"https:\/\/statorials.org\/pt\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Como usar a fun\u00e7\u00e3o runif em R (4 exemplos) \u2013 Estatologia","description":"Este tutorial explica como usar a fun\u00e7\u00e3o runif() em R para gerar valores aleat\u00f3rios a partir da distribui\u00e7\u00e3o uniforme.","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\/pt\/runif-em-r\/","og_locale":"pt_PT","og_type":"article","og_title":"Como usar a fun\u00e7\u00e3o runif em R (4 exemplos) \u2013 Estatologia","og_description":"Este tutorial explica como usar a fun\u00e7\u00e3o runif() em R para gerar valores aleat\u00f3rios a partir da distribui\u00e7\u00e3o uniforme.","og_url":"https:\/\/statorials.org\/pt\/runif-em-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. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/runif-em-r\/","url":"https:\/\/statorials.org\/pt\/runif-em-r\/","name":"Como usar a fun\u00e7\u00e3o runif em R (4 exemplos) \u2013 Estatologia","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-19T18:16:07+00:00","dateModified":"2023-07-19T18:16:07+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como usar a fun\u00e7\u00e3o runif() em R para gerar valores aleat\u00f3rios a partir da distribui\u00e7\u00e3o uniforme.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/runif-em-r\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/runif-em-r\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/runif-em-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como usar a fun\u00e7\u00e3o runif em r (4 exemplos)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pt\/#website","url":"https:\/\/statorials.org\/pt\/","name":"Statorials","description":"O seu guia para a literacia estat\u00edstica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pt\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-PT"},{"@type":"Person","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666","name":"Dr. benjamim anderson","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr. benjamim anderson"},"description":"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais","sameAs":["https:\/\/statorials.org\/pt"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/comments?post=2990"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/2990\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=2990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=2990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=2990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}