{"id":15,"date":"2016-12-08T08:18:27","date_gmt":"2016-12-08T08:18:27","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=15"},"modified":"2016-12-08T08:18:47","modified_gmt":"2016-12-08T08:18:47","slug":"example-3-binomial-distribution-n100","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2016\/12\/example-3-binomial-distribution-n100\/","title":{"rendered":"Example 3: Binomial distribution, n=100"},"content":{"rendered":"<p>Example 3: Binomial distribution, n=100<\/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 = range(101)<br \/>\nn,p = 100,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(\"example3.png\", dpi=100)<br \/>\nplt.show()<br \/>\nplt.close()<br \/>\n<\/code><\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full wp-image-16\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example3.png?resize=600%2C400\" alt=\"example3\" width=\"600\" height=\"400\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example3.png?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example3.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example 3: Binomial distribution, n=100 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 = range(101) n,p = 100,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;example3.png&#8221;, dpi=100) plt.show() plt.close()<\/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_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[2],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-python"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-f","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":11,"url":"https:\/\/gantovnik.com\/bio-tips\/2016\/12\/example-2-binomial-distribution-n6\/","url_meta":{"origin":15,"position":0},"title":"Example 2: Binomial distribution, n=6","author":"gantovnik","date":"2016-12-08","format":false,"excerpt":"Example 2: Binomial distribution, n=6 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 = [0,1,2,3,4,5,6] n,p = 6,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(\"example2.png\", dpi=100) plt.show() plt.close() Plot:","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example2","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2016\/12\/example2-300x200.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":203,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/laplace-equation-2d\/","url_meta":{"origin":15,"position":1},"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":248,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/clustering\/","url_meta":{"origin":15,"position":2},"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":68,"url":"https:\/\/gantovnik.com\/bio-tips\/2018\/12\/linear-regression-of-nonlinear-function\/","url_meta":{"origin":15,"position":3},"title":"Linear regression of nonlinear function","author":"gantovnik","date":"2018-12-24","format":false,"excerpt":"import os import matplotlib.pyplot as plt import numpy as np import math os.chdir('\/home\/vg\/Downloads\/projects\/ex10') os.getcwd() plt.figure(figsize=(10,8)) N = 100 start = 0 end = 2 A = np.random.rand() + 0.5 B = np.random.rand() x = np.linspace(start,end,N) y = B*np.exp(A*x) y = y + np.random.randn(N)\/5 p = np.polyfit(x,np.log(y),1) plt.plot(x,y,'o',label='Given data: A=%.2f. B=%.2f'\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example10","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2018\/12\/example10.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2018\/12\/example10.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2018\/12\/example10.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":15,"position":4},"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":[]},{"id":133,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/spline-interpolation-3\/","url_meta":{"origin":15,"position":5},"title":"#27 Spline interpolation","author":"gantovnik","date":"2019-01-03","format":false,"excerpt":"import os import matplotlib.pyplot as plt import numpy as np from scipy import interpolate os.chdir(r'D:\\data\\scripts\\web1\\ex27') os.getcwd() x = np.array([0, 1, 2, 3, 4, 5, 6, 7]) y = np.array([3, 4, 3.5, 2, 1, 1.5, 1.25, 0.9]) xx = np.linspace(x.min(), x.max(), 100) fig, ax = plt.subplots(figsize=(8, 4)) ax.scatter(x, y) for n\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example27","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example27.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example27.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example27.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/15","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=15"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}