| Hosted by CoCalc | Download
# Use a better version of the octave interface from octave import octave %default_mode octave
a = [1 2 3]
a = 1 2 3
randn(10)
ans = 0.798982 0.416724 2.18233 -1.09068 0.352254 -0.732456 -1.124 0.834815 0.743071 0.241821 0.18994 0.557849 -0.104051 -1.99889 0.687714 -0.284198 0.47189 2.38063 -0.452398 0.358618 -0.158394 0.128113 0.821027 1.08713 -0.198243 -0.372265 -1.22696 -0.0447861 0.406983 -0.165757 0.226805 0.181686 -0.292095 0.233667 -0.724688 -1.90594 -0.376189 -0.0619956 1.05597 -0.273184 1.31549 0.709709 0.0892381 -0.626299 0.0435771 1.35619 0.188526 -0.309399 0.0965437 0.216237 -1.34232 0.373958 0.0236513 0.644659 -1.94868 -1.01742 0.251857 1.78829 1.11657 -1.92372 -0.878848 1.97721 0.0151574 -0.152182 -1.54449 -0.290301 1.12923 -1.73619 1.35395 -0.16647 0.50124 -0.843304 -0.948814 0.719464 -0.640613 0.640123 -1.23381 0.112673 1.01801 -0.488985 -0.536001 0.540205 -0.0114873 0.834419 0.762442 -0.500653 -1.46816 0.060272 -0.721399 0.324182 -1.42255 1.57149 0.642925 1.62612 -1.13336 1.64757 0.152923 -1.03906 0.437521 -0.0167182
randn(10)
ans = -0.199595 -0.612382 -0.160434 -1.73094 1.28621 -0.0457435 -0.159221 1.00144 -0.330306 0.263694 -1.35208 -0.314644 0.113127 -0.450984 0.335473 -0.131073 0.188683 -0.311885 -0.105881 0.158006 0.812281 1.62297 -0.913395 -0.740859 0.0210177 0.689689 0.625797 -1.276 -0.727256 -2.21563 1.13034 0.969458 -1.26382 -0.539445 0.38801 1.05427 0.475499 1.99847 0.099152 -1.09846 1.85823 1.4477 0.081904 0.372824 0.6236 0.697474 -0.571202 -2.09211 -0.248568 1.20367 -0.89818 0.640905 1.87064 -2.00252 -0.905163 0.508392 0.348124 -0.0775619 -0.315217 0.931731 -0.976787 -0.299786 1.79709 -1.43326 -1.55786 1.82049 1.1324 -0.476884 1.09377 0.11956 0.00194084 -0.508266 0.738512 -1.43635 -1.40105 -0.565737 0.0275779 1.42439 0.687259 0.130321 0.97336 -1.26436 -1.4445 1.74509 -1.17279 -0.951912 -1.04651 -2.12591 -0.134867 0.659644 -1.2732 0.548467 -0.503037 1.47305 -1.89546 -0.0260827 -1.54173 0.770912 0.545161 -0.386708

Deliberate syntax error

x + 1 = 2
parse error: invalid left hand side of assignment >>> x + 1 = 2 ^
x = 2 - 1
x = 1

Demonstrate Octave --> Sage graphics

#Find a good increment to use to explore points near tails endval=0.999; incval=2*endval/20; xuniform=[-endval:incval:endval]'; %For the simple test yuniform=[-endval:incval:endval]'; %For the simple test #For a Gaussian 2D density with zero covariance the density is factorable permitting... #Use inverse error function to generate a Gaussian marginal distribution of trajectories xvalues=erfinv(xuniform); yvalues=erfinv(yuniform); nxv=size(xvalues,1); nyv=size(yvalues,1); N=nxv*nyv; %Number of worlds #We need to build the 2D coordinates obtained from Cartesian product of x and y coordinates [Xc, Yc] = meshgrid (xvalues, yvalues); #X is the state vector, a single column with every x and y coordinate as an entry followed #by every time derivative of these coordinates #For the 2D case our stacking will be of all x coordinates first, then all y, then derivatives Xcol=reshape(Xc,N,1); Ycol=reshape(Yc,N,1);
#The function voronoin will generate two lists: #C contains the vertices of the Voronoi polygons. #F contains, for each original point, the indices of the Voronoi polygon vertices. #while polyarea will create the areas of each voronoi polygon for us [C, F] = voronoin ([Xcol, Ycol]); af = zeros (size (F)); for i = 1 : length (F) af(i) = polyarea (C (F {i, :}, 1), C (F {i, :}, 2)); endfor #display(af) #display areas #So the probability density associated with each trajectory point is Pin=(N*af).^(-1); %Plot the input trajectory density #Next 2 lines only needed to avoid plot data error Pf=Pin; Pf(isnan(Pin))=0;
%sage m=matrix(RR,octave("[Xcol(:), Ycol(:), Pf(:)]")) data=[(x,y,z) for x,y,z in m.rows()] surface=list_plot3d(data,aspect_ratio=[1,1,8],texture={'color':'green','opacity':0.85,'ambient':0.9}) pts=points(data,size=2,color='red') show(surface+pts,spin=10,background='pink',height=int(600),width=int(1000),renderer='webgl',frame={'thickness':4.0, 'color ':'red','labels' : True,'fontface' : 'roman'} )
/projects/sage/sage-6.10/local/lib/python2.7/site-packages/matplotlib-1.5.0-py2.7-linux-x86_64.egg/matplotlib/cbook.py:136: MatplotlibDeprecationWarning: The matplotlib.delaunay module was deprecated in version 1.4. Use matplotlib.tri.Triangulation instead. warnings.warn(message, mplDeprecation, stacklevel=1)
3D rendering not yet implemented