{"id":1592,"date":"2022-10-23T02:31:01","date_gmt":"2022-10-23T09:31:01","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1592"},"modified":"2022-10-23T02:32:08","modified_gmt":"2022-10-23T09:32:08","slug":"210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-3-2-2-3-2-2-3","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2022\/10\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-3-2-2-3-2-2-3\/","title":{"rendered":"#304 Julia set using Octave script"},"content":{"rendered":"<p>Place both files: julia.m and juliatest.m in the same folder:<\/p>\n<pre>julia.m<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#{\r\nCalculate a Julia set\r\nzmin = minimum value of c\r\nzmax = maximum value of c\r\nhpx = number of horizontal pixels\r\nniter = Number of iterations\r\nc = complex number\r\n#}\r\nfunction M = julia(zmin, zmax, hpx, niter, c)\r\n%% Number of vertical pixels\r\nvpx=round(hpx*abs(imag(zmax-zmin)\/real(zmax-zmin)));\r\n%% Prepare the complex plane\r\n&#x5B;zRe,zIm]=meshgrid(linspace(real(zmin),real(zmax),hpx),\r\nlinspace(imag(zmin),imag(zmax),vpx));\r\nz=zRe+i*zIm;\r\nM=zeros(vpx,hpx);\r\n%% Generate Julia\r\nfor s=1:niter\r\nmask=abs(z)&lt;2;\r\nM(mask)=M(mask)+1;\r\nz(mask)=z(mask).^2+c;\r\nend\r\nM(mask)=0;\r\nend\r\n<\/pre>\n<pre>run juliatest.m<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nJc1=julia(-1.6+1.2i, 1.6-1.2i, 640, 128, -0.75+0.2i);\r\nimagesc(Jc1)\r\naxis off\r\ncolormap(turbo)\r\nend <\/pre>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-medium wp-image-1593\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/10\/2022-10-23_022754.png?resize=300%2C239&#038;ssl=1\" alt=\"\" width=\"300\" height=\"239\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/10\/2022-10-23_022754.png?resize=300%2C239&amp;ssl=1 300w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/10\/2022-10-23_022754.png?resize=150%2C119&amp;ssl=1 150w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/10\/2022-10-23_022754.png?w=452&amp;ssl=1 452w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Place both files: julia.m and juliatest.m in the same folder: julia.m #{ Calculate a Julia set zmin = minimum value of c zmax = maximum value of c hpx = number of horizontal pixels niter = Number of iterations c = complex number #} function M = julia(zmin, zmax, hpx, niter, c) %% Number of [&hellip;]<\/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":[49],"tags":[],"class_list":["post-1592","post","type-post","status-publish","format-standard","hentry","category-octave"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-pG","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":197,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/julia-fractal\/","url_meta":{"origin":1592,"position":0},"title":"Julia fractal","author":"gantovnik","date":"2019-01-10","format":false,"excerpt":"import os import numba import numpy as np import matplotlib.pyplot as plt os.chdir(r'D:\\projects\\wordpress\\ex40') os.getcwd() def py_julia_fractal(z_re, z_im, j): for m in range(len(z_re)): for n in range(len(z_im)): z = z_re[m] + 1j * z_im[n] for t in range(256): z = z ** 2 - 0.05 + 0.68j if np.abs(z) > 2.0:\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"example40","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example40.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example40.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example40.png?resize=525%2C300 1.5x"},"classes":[]},{"id":248,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/clustering\/","url_meta":{"origin":1592,"position":1},"title":"#49 Clustering","author":"gantovnik","date":"2019-01-13","format":false,"excerpt":"[code language=\"python\"] import os import numpy as np import matplotlib.pyplot as plt from sklearn import datasets from sklearn import metrics from sklearn import cluster os.chdir(r'D:\\projects\\wordpress\\ex49') os.getcwd() iris = datasets.load_iris() X, y = iris.data, iris.target np.random.seed(123) n_clusters = 3 c = cluster.KMeans(n_clusters=n_clusters) c.fit(X) y_pred = c.predict(X) print(y_pred[::8]) print(y[::8]) idx_0, idx_1, idx_2\u2026","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":1176,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/204-mandelbrot-fractal-using-python\/","url_meta":{"origin":1592,"position":2},"title":"#204 Mandelbrot fractal using python","author":"gantovnik","date":"2021-11-26","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt def mandelbrot(h,w, maxit=20): x,y = np.meshgrid(np.linspace(-2, 0.8, w), np.linspace(-1.4, 1.4, h)) c = x + y*1j z = c exceeds = np.zeros(z.shape, dtype=bool) for iteration in range(maxit): z = z**2 + c exceeded = abs(z) > 4 exceeds_now = exceeded\u2026","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\/ex204.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1194,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/204-mandelbrot-fractal-using-python-2-2-2-2-2\/","url_meta":{"origin":1592,"position":3},"title":"#209 3D wireframe plots","author":"gantovnik","date":"2021-11-27","format":false,"excerpt":"[code language=\"python\"] from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 12), subplot_kw={'projection': '3d'}) # Get the test data X, Y, Z = axes3d.get_test_data(0.05) # Give the first plot only wireframes of the type y = c ax1.plot_wireframe(X, Y, Z, rstride=10, cstride=0) ax1.set_title(&quot;Column (x)\u2026","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\/ex209.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex209.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex209.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2162,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/05\/422-barnsleys-fern-using-imshow\/","url_meta":{"origin":1592,"position":4},"title":"#422  Barnsley\u2019s fern using imshow","author":"gantovnik","date":"2024-05-04","format":false,"excerpt":"The Axes method ax.imshow displays an image on the axes. In its basic usage, it takes a two-dimensional array and maps its values to the pixels on an image according to some interpolation scheme and normalization. In this case, im is a three-dimensional array of shape (n, m, 3) in\u2026","rel":"","context":"In &quot;matplotlib&quot;","block_context":{"text":"matplotlib","link":"https:\/\/gantovnik.com\/bio-tips\/category\/matplotlib\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/05\/ex422.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/05\/ex422.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2024\/05\/ex422.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1742,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/01\/204-mandelbrot-fractal-using-python-2-2-2-2-2-2-2-2-2\/","url_meta":{"origin":1592,"position":5},"title":"#330 Gradient method using python","author":"gantovnik","date":"2023-01-03","format":false,"excerpt":"golden.py [code language=\"python\"] import math as mt def golden(f,a,b,tol=1.0e-10): # Golden section method for determining x # that minimizes the scalar function f(x). # The minimum must be bracketed in (a,b). c1 = (mt.sqrt(5.0)-1.0)\/2.0 c2 = 1.0 - c1 nIt = int(mt.ceil(mt.log(tol\/abs(a-b))\/mt.log(c1))) # first step x1 = c1*a + c2*b\u2026","rel":"","context":"In &quot;optimization&quot;","block_context":{"text":"optimization","link":"https:\/\/gantovnik.com\/bio-tips\/category\/optimization\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/01\/ex330.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1592","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=1592"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1592\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}