{"id":11,"date":"2016-12-08T08:10:25","date_gmt":"2016-12-08T08:10:25","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=11"},"modified":"2016-12-08T08:10:25","modified_gmt":"2016-12-08T08:10:25","slug":"example-2-binomial-distribution-n6","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2016\/12\/example-2-binomial-distribution-n6\/","title":{"rendered":"Example 2: Binomial distribution, n=6"},"content":{"rendered":"<p>Example 2: Binomial distribution, n=6<\/p>\n<p><code><br \/>\nimport matplotlib.pyplot as plt<br \/>\nfrom scipy.stats import binom<br \/>\nimport os<br \/>\nos.chdir('C:\\\\Anaconda\\\\mycodes\\\\aerospace')<br \/>\nos.getcwd()<br \/>\nfig,ax = plt.subplots(1,1)<br \/>\nx = [0,1,2,3,4,5,6]\nn,p = 6,0.5<br \/>\nrv = binom(n,p)<br \/>\nax.vlines(x,0,rv.pmf(x),colors='k',linestyles='-',lw=1,label='Probability')<br \/>\nax.legend(loc='best',frameon=False)<br \/>\nplt.savefig(\"example2.png\", dpi=100)<br \/>\nplt.show()<br \/>\nplt.close()<br \/>\n<\/code><\/p>\n<p>Plot:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-medium wp-image-12\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example2-300x200.png?resize=300%2C200\" alt=\"example2\" width=\"300\" height=\"200\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example2.png?resize=300%2C200&amp;ssl=1 300w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example2.png?w=600&amp;ssl=1 600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example 2: Binomial distribution, n=6 import matplotlib.pyplot as plt from scipy.stats import binom import os os.chdir(&#8216;C:\\\\Anaconda\\\\mycodes\\\\aerospace&#8217;) os.getcwd() fig,ax = plt.subplots(1,1) x = [0,1,2,3,4,5,6] n,p = 6,0.5 rv = binom(n,p) ax.vlines(x,0,rv.pmf(x),colors=&#8217;k&#8217;,linestyles=&#8217;-&#8216;,lw=1,label=&#8217;Probability&#8217;) ax.legend(loc=&#8217;best&#8217;,frameon=False) plt.savefig(&#8220;example2.png&#8221;, dpi=100) plt.show() plt.close() Plot:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2],"tags":[5],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-python","tag-binomial-distribution"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-b","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":15,"url":"https:\/\/gantovnik.com\/bio-tips\/2016\/12\/example-3-binomial-distribution-n100\/","url_meta":{"origin":11,"position":0},"title":"Example 3: Binomial distribution, n=100","author":"gantovnik","date":"2016-12-08","format":false,"excerpt":"Example 3: Binomial distribution, n=100 import matplotlib.pyplot as plt from scipy.stats import binom import os os.chdir('C:\\\\Anaconda\\\\mycodes\\\\aerospace') os.getcwd() fig,ax = plt.subplots(1,1) x = range(101) n,p = 100,0.5 rv = binom(n,p) ax.vlines(x,0,rv.pmf(x),colors='k',linestyles='-',lw=1,label='Probability') ax.legend(loc='best',frameon=False) plt.savefig(\"example3.png\", dpi=100) plt.show() plt.close()","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example3","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example3.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example3.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example3.png?resize=525%2C300 1.5x"},"classes":[]},{"id":248,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/clustering\/","url_meta":{"origin":11,"position":1},"title":"#49 Clustering","author":"gantovnik","date":"2019-01-13","format":false,"excerpt":"\u00a0 \u00a0","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example49","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example49.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example49.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example49.png?resize=525%2C300 1.5x"},"classes":[]},{"id":1147,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/201-polyfit-and-polyval-2\/","url_meta":{"origin":11,"position":2},"title":"#202 Histogram using seaborn","author":"gantovnik","date":"2021-11-23","format":false,"excerpt":"Note LaTeX format in the plot title!","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex202-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex202-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex202-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex202-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":203,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/laplace-equation-2d\/","url_meta":{"origin":11,"position":3},"title":"Laplace equation (2D)","author":"gantovnik","date":"2019-01-10","format":false,"excerpt":"import os import numpy as np import matplotlib.pyplot as plt import scipy.sparse as sp import matplotlib as mpl import scipy.sparse.linalg os.chdir(r'D:\\projects\\wordpress\\ex42') os.getcwd() N = 100 u0_t, u0_b = 5, -5 u0_l, u0_r = 3, -1 dx = 1. \/ (N+1) A_1d = (sp.eye(N, k=-1) + sp.eye(N, k=1) - 4 *\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example42","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example42.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example42.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example42.png?resize=525%2C300 1.5x"},"classes":[]},{"id":127,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/runge-problem\/","url_meta":{"origin":11,"position":4},"title":"Runge problem","author":"gantovnik","date":"2019-01-03","format":false,"excerpt":"import os import matplotlib.pyplot as plt import numpy as np from numpy import polynomial as P os.chdir(r'D:\\data\\scripts\\web1\\ex25') os.getcwd() # In the mathematical field of numerical analysis, Runge's phenomenon # is a problem of oscillation at the edges of an interval that occurs # when using polynomial interpolation with polynomials of\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example25","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example25.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example25.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example25.png?resize=525%2C300 1.5x"},"classes":[]},{"id":365,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/solution-of-laplace-equation-using-fem\/","url_meta":{"origin":11,"position":5},"title":"#51 Solution of Laplace equation using FEM","author":"gantovnik","date":"2019-01-29","format":false,"excerpt":"","rel":"","context":"In &quot;fem&quot;","block_context":{"text":"fem","link":"https:\/\/gantovnik.com\/bio-tips\/category\/fem\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example61_3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example61_3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example61_3.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}