julia

Optimal way to compute permutations in julia

五迷三道 提交于 2021-02-18 11:38:09
问题 Consider a list [1,1,1,...,1,0,0,...,0] (an arbitrary list of zeros and ones). We want the whole possible permutations in this array, there'll be binomial(l,k) permutations ( l stands for the length of the list and k for the number of ones in the list). Right now, I have tested three different algorithms to generate the whole possible permutations, one that uses a recurrent function, one that calculates the permutations via calculating the interval number [1,...,1,0,0,...,0] to [0,0,...0,1,1,

Julia Dataframes vs Python pandas

你离开我真会死。 提交于 2021-02-18 09:55:02
问题 I am currently using python pandas and want to know if there is a way to output the data from pandas into julia Dataframes and vice versa. (I think you can call python from Julia with Pycall but I am not sure if it works with dataframes) Is there a way to call Julia from python and have it take in panda s dataframes? (without saving to another file format like csv) When would it be advantageous to use Julia Dataframes than Pandas other than extremely large datasets and running things with

Logistic regression in Julia using Optim.jl

江枫思渺然 提交于 2021-02-17 22:53:13
问题 I'm trying to implement a simple regularized logistic regression algorithm in Julia. I'd like to use Optim.jl library to minimize my cost function, but I can't get it to work. My cost function and gradient are as follows: function cost(X, y, theta, lambda) m = length(y) h = sigmoid(X * theta) reg = (lambda / (2*m)) * sum(theta[2:end].^2) J = (1/m) * sum( (-y).*log(h) - (1-y).*log(1-h) ) + reg return J end function grad(X, y, theta, lambda, gradient) m = length(y) h = sigmoid(X * theta) #

Julia: Sort Matrix by column 2 then 3

僤鯓⒐⒋嵵緔 提交于 2021-02-17 14:47:04
问题 I would like to sort my matrix A by column 2 then 3. A = round.(randn(100,4)) Maybe something like: sort(A,(0,2:3)) 100x4 Array{Float64,2}: 0.0 -2.0 -2.0 -1.0 -1.0 -2.0 -1.0 1.0 1.0 -2.0 -1.0 2.0 -1.0 -2.0 0.0 0.0 -1.0 -2.0 0.0 -1.0 -0.0 -2.0 0.0 -1.0 1.0 -2.0 0.0 0.0 1.0 -2.0 1.0 -1.0 -0.0 -2.0 2.0 -1.0 -0.0 -1.0 -2.0 1.0 ⋮ -0.0 1.0 0.0 1.0 1.0 1.0 1.0 1.0 0.0 1.0 1.0 -1.0 -0.0 1.0 2.0 0.0 -0.0 2.0 -1.0 0.0 -2.0 2.0 -1.0 1.0 2.0 2.0 -0.0 -1.0 -1.0 2.0 -0.0 -1.0 1.0 2.0 0.0 2.0 -1.0 2.0 2.0 0

VS code, julia linter doesn't work (on mac)

你。 提交于 2021-02-17 02:04:12
问题 having assured myself that julia is enabled and that the linter is too (in vs code settings: Julia › Lint: Run), i get syntax highlighting on my xxx.jl script but no linting at all. im on the latest vs code + latest julia 1.07 extension + latest macosx. i did a clean installation of vs code, wiping all old related folders prior to installation (https://stackoverflow.com/a/53839847/11608725) so julia is the only extension/package installed, no conflicts should be present. what am i missing?

Julia challenge - FitzHugh–Nagumo model PDE Runge-Kutta solver

↘锁芯ラ 提交于 2021-02-11 11:52:59
问题 I am newbie in Julia programming language, so I don't know much of how to optimize a code. I have heard that Julia should be faster in comparison to Python, but I've written a simple Julia code for solving the FitzHugh–Nagumo model , and it doesn't seems to be faster than Python. The FitzHugh–Nagumo model equations are: function FHN_equation(u,v,a0,a1,d,eps,dx) u_t = u - u.^3 - v + laplacian(u,dx) v_t = eps.*(u - a1 * v - a0) + d*laplacian(v,dx) return u_t, v_t end where u and v are the

Julia challenge - FitzHugh–Nagumo model PDE Runge-Kutta solver

☆樱花仙子☆ 提交于 2021-02-11 11:52:49
问题 I am newbie in Julia programming language, so I don't know much of how to optimize a code. I have heard that Julia should be faster in comparison to Python, but I've written a simple Julia code for solving the FitzHugh–Nagumo model , and it doesn't seems to be faster than Python. The FitzHugh–Nagumo model equations are: function FHN_equation(u,v,a0,a1,d,eps,dx) u_t = u - u.^3 - v + laplacian(u,dx) v_t = eps.*(u - a1 * v - a0) + d*laplacian(v,dx) return u_t, v_t end where u and v are the

How can I run a simple parallel array assignment operation in Julia?

好久不见. 提交于 2021-02-10 14:03:34
问题 I have to solve a differential equations system many times, iterating over a parameter. For this, I run a loop over a list of the parameter, and store the solution (evaluated at an array of time values) for each parameter. So I have a 2D array in which I store solutions (each row is for a value of the parameter). Now, since any iteration has nothing to do with another one, I thought of doing this in parallel. Here is my code: using DifferentialEquations using SharedArrays using DelimitedFiles

How can I run a simple parallel array assignment operation in Julia?

蓝咒 提交于 2021-02-10 14:02:08
问题 I have to solve a differential equations system many times, iterating over a parameter. For this, I run a loop over a list of the parameter, and store the solution (evaluated at an array of time values) for each parameter. So I have a 2D array in which I store solutions (each row is for a value of the parameter). Now, since any iteration has nothing to do with another one, I thought of doing this in parallel. Here is my code: using DifferentialEquations using SharedArrays using DelimitedFiles

is there any possibility to change the RHS of non-linear constraints in julia?

耗尽温柔 提交于 2021-02-10 12:51:59
问题 Is there any possibility to change the RHS of non-linear constraints? using JuMP, Ipopt, Juniper,Gurobi,CPUTime T=0; ZT=zeros(2,1); ZB=zeros(2,1); #-----Model parameters-------------------------------------------------------- sig=0.86; landa=50; E=T0=T1=.0833; T2=0.75; gam2=1; gam1=0; a1=5; a2=4.22; a3=977.4; ap=977.4; C1=949.2; c0=114.24; f(x) = cdf(Normal(0, 1), x); #--------------------------------------------------------------------------- ALT= Model(optimizer_with_attributes(Juniper