{"id":3202,"date":"2023-07-18T17:14:14","date_gmt":"2023-07-18T17:14:14","guid":{"rendered":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/"},"modified":"2023-07-18T17:14:14","modified_gmt":"2023-07-18T17:14:14","slug":"numpy-zufallsmatrix","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/","title":{"rendered":"So erstellen sie eine numpy-matrix mit zufallszahlen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Sie k\u00f6nnen die folgenden Methoden verwenden, um eine NumPy-Matrix mit Zufallszahlen zu erstellen:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: Erstellen Sie eine NumPy-Matrix aus zuf\u00e4lligen Ganzzahlen<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>n.p. <span style=\"color: #3366ff;\">random<\/span> . <span style=\"color: #3366ff;\">randint<\/span> (low, high, (rows, columns))\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 2: Erstellen Sie eine NumPy-Matrix aus zuf\u00e4lligen Gleitkommazahlen<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>n.p. <span style=\"color: #3366ff;\">random<\/span> . <span style=\"color: #3366ff;\">rand<\/span> (rows, columns)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Die folgenden Beispiele zeigen, wie die einzelnen Methoden in der Praxis angewendet werden.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel 1: Erstellen Sie eine NumPy-Matrix aus zuf\u00e4lligen Ganzzahlen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie man eine NumPy-Matrix aus Zufallswerten im Bereich von <strong>0<\/strong> bis <strong>20<\/strong> mit einer Form aus <strong>7 Zeilen<\/strong> und <strong>2 Spalten<\/strong> erstellt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create NumPy matrix of random integers\n<\/span>n.p. <span style=\"color: #3366ff;\">random<\/span> . <span style=\"color: #3366ff;\">randint<\/span> (0, 20, (7, 2))\n\narray([[ 3, 7],\n       [17, 10],\n       [0, 10],\n       [13, 16],\n       [6, 14],\n       [8, 7],\n       [9, 15]])<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass jeder Wert in der Matrix zwischen 0 und 20 liegt und die endg\u00fcltige Form der Matrix aus 7 Zeilen und 2 Spalten besteht.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel 2:<\/strong><\/span> <strong style=\"color: #000000;\">Erstellen Sie eine NumPy-Matrix aus zuf\u00e4lligen Gleitkommazahlen<\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie man eine NumPy-Matrix mit zuf\u00e4lligen Float-Werten zwischen <strong>0<\/strong> und <strong>1<\/strong> und einer Form aus <strong>7<\/strong> Spalten und <strong>2<\/strong> Zeilen erstellt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create NumPy matrix of random floats\n<\/span>n.p. <span style=\"color: #3366ff;\">random<\/span> . <span style=\"color: #3366ff;\">rand<\/span> (7, 2)\n\narray([[0.64987774, 0.60099292],\n       [0.13626106, 0.1859029 ],\n       [0.77007972, 0.65179164],\n       [0.33524707, 0.46201819],\n       [0.1683, 0.72960909],\n       [0.76117417, 0.37212974],\n       [0.18879731, 0.65723325]])\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Das Ergebnis ist eine NumPy-Matrix, die zuf\u00e4llige Float-Werte zwischen 0 und 1 mit einer Form aus 7 Zeilen und 2 Spalten enth\u00e4lt.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass Sie auch die NumPy-Funktion \u201e <strong>round()\u201c<\/strong> verwenden k\u00f6nnen, um jede Gleitkommazahl auf eine bestimmte Anzahl von Dezimalstellen zu runden.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt beispielsweise, wie man eine NumPy-Matrix aus zuf\u00e4lligen Gleitkommazahlen erstellt, die jeweils auf zwei Dezimalstellen gerundet sind:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#create NumPy matrix of random floats rounded to 2 decimal places\n<\/span>n.p. <span style=\"color: #3366ff;\">round<\/span> (np. <span style=\"color: #3366ff;\">random<\/span> . <span style=\"color: #3366ff;\">rand<\/span> (5, 2), 2)\n\narray([[0.37, 0.63],\n       [0.51, 0.68],\n       [0.23, 0.98],\n       [0.62, 0.46],\n       [0.02, 0.94]])\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Hinweis<\/strong> : Die vollst\u00e4ndige Dokumentation f\u00fcr die NumPy-Funktion <strong>rand()<\/strong> finden Sie <a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/random\/generated\/numpy.random.rand.html\" target=\"_blank\" rel=\"noopener\">hier<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In den folgenden Tutorials wird erl\u00e4utert, wie Sie andere g\u00e4ngige Konvertierungen in Python durchf\u00fchren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/pandas-an-einer-schnur\/\" target=\"_blank\" rel=\"noopener\">So konvertieren Sie Pandas DataFrame-Spalten in Zeichenfolgen<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/pandas-zeitstempel-datum-uhrzeit\/\" target=\"_blank\" rel=\"noopener\">So konvertieren Sie den Zeitstempel in Pandas in Datum\/Uhrzeit<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/konvertieren-sie-datetime-in-date-pandas\/\" target=\"_blank\" rel=\"noopener\">So konvertieren Sie DateTime in Pandas in ein Datum<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sie k\u00f6nnen die folgenden Methoden verwenden, um eine NumPy-Matrix mit Zufallszahlen zu erstellen: Methode 1: Erstellen Sie eine NumPy-Matrix aus zuf\u00e4lligen Ganzzahlen n.p. random . randint (low, high, (rows, columns)) Methode 2: Erstellen Sie eine NumPy-Matrix aus zuf\u00e4lligen Gleitkommazahlen n.p. random . rand (rows, columns) Die folgenden Beispiele zeigen, wie die einzelnen Methoden in der [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>So erstellen Sie eine NumPy-Matrix mit Zufallszahlen \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand von Beispielen erl\u00e4utert, wie Sie mit NumPy eine Matrix mit Zufallszahlen erstellen.\" \/>\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\/de\/numpy-zufallsmatrix\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So erstellen Sie eine NumPy-Matrix mit Zufallszahlen \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand von Beispielen erl\u00e4utert, wie Sie mit NumPy eine Matrix mit Zufallszahlen erstellen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T17:14:14+00:00\" \/>\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 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/\",\"url\":\"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/\",\"name\":\"So erstellen Sie eine NumPy-Matrix mit Zufallszahlen \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-18T17:14:14+00:00\",\"dateModified\":\"2023-07-18T17:14:14+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand von Beispielen erl\u00e4utert, wie Sie mit NumPy eine Matrix mit Zufallszahlen erstellen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So erstellen sie eine numpy-matrix mit zufallszahlen\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/de\/#website\",\"url\":\"https:\/\/statorials.org\/de\/\",\"name\":\"Statorials\",\"description\":\"Ihr Leitfaden f\u00fcr statistische Kompetenz !\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de-DE\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\",\"name\":\"Dr. Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-DE\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. Benjamin Anderson\"},\"description\":\"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen\",\"sameAs\":[\"https:\/\/statorials.org\/de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"So erstellen Sie eine NumPy-Matrix mit Zufallszahlen \u2013 Statorials","description":"In diesem Tutorial wird anhand von Beispielen erl\u00e4utert, wie Sie mit NumPy eine Matrix mit Zufallszahlen erstellen.","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\/de\/numpy-zufallsmatrix\/","og_locale":"de_DE","og_type":"article","og_title":"So erstellen Sie eine NumPy-Matrix mit Zufallszahlen \u2013 Statorials","og_description":"In diesem Tutorial wird anhand von Beispielen erl\u00e4utert, wie Sie mit NumPy eine Matrix mit Zufallszahlen erstellen.","og_url":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/","og_site_name":"Statorials","article_published_time":"2023-07-18T17:14:14+00:00","author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"2 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/","url":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/","name":"So erstellen Sie eine NumPy-Matrix mit Zufallszahlen \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-18T17:14:14+00:00","dateModified":"2023-07-18T17:14:14+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand von Beispielen erl\u00e4utert, wie Sie mit NumPy eine Matrix mit Zufallszahlen erstellen.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/numpy-zufallsmatrix\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So erstellen sie eine numpy-matrix mit zufallszahlen"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/de\/#website","url":"https:\/\/statorials.org\/de\/","name":"Statorials","description":"Ihr Leitfaden f\u00fcr statistische Kompetenz !","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de-DE"},{"@type":"Person","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0","name":"Dr. Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"de-DE","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Dr. Benjamin Anderson"},"description":"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen","sameAs":["https:\/\/statorials.org\/de"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3202"}],"collection":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/comments?post=3202"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3202\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=3202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=3202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=3202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}