DifferentialEquations.jl Not Working w/ Julia 1.5? - julia

using DifferentialEquations
f(u,p,t) = 1.01*u
u0 = 1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob, Tsit5(), reltol=1e-8, abstol=1e-8)
using Plots
plot(sol,linewidth=5,title="Solution to the linear ODE with a thick line",
xaxis="Time (t)",yaxis="u(t) (in μm)",label="My Thick Line!") # legend=false
plot!(sol.t, t->0.5*exp(1.01t),lw=3,ls=:dash,label="True Solution!")
This is a sample code from the DifferentialEquations.jl documentation and whenever I try to run this I get that UndefVarError: plot! not defined
A similar error arrises when just executing a simpler version
using DifferentialEquations
f(u,p,t) = 1.01*u
u0 = 1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
println(prob)
UndefVarError: ODEProblem not defined
I ran status and these are the current versions I am running Julia 1.5.1 (first install today) on Windows 10:
Atom v0.12.21
DifferentialEquations v6.15.0
IJulia v1.21.3
Juno v0.8.3

Could you please share the whole error message? You should look at the first error, which is likely due to not adding the package, and follow the steps of that error message. It looks like you never added Plots.jl, so using Plots should have failed.

Related

Why does running the tutorial example fail with Rstan?

I installed the RStan successfully, the library loads. I try to run a tutorial example (https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#example-1-eight-schools). After applying the stan function
fit1 <- stan(
file = "schools.stan", # Stan program
data = schools_data, # named list of data
chains = 4, # number of Markov chains
warmup = 1000, # number of warmup iterations per chain
iter = 2000, # total number of iterations per chain
cores = 1, # number of cores (could use one per chain)
refresh = 0 # no progress shown
)
I get the following error:
*Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1c34165764a4.o:file1c34165764a4.cpp:(.text$_ZN3tbb10interface
Error in sink(type = "output") : invalid connection*
Simply running example(stan_model, run.dontrun=T) gives the same error.
What does this error mean?
Is rtools wrongly installed? My PATH seems to contain the correct folder C:\\rtools42\\x86_64-w64-mingw32.static.posix\\bin;. Is something wrong with the version of my Rstan package? I am struggling to interpret this error?
What to try to solve it?
Apparently Rtools42 in incompatible with the current version Rstan on CRAN. The solution that worked for me is found here: https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows#r-42

Can I run R parallel computing along side JuliaCall?

I have an R function code that runs with JuliaCall. However, due to the computation time, I would like to parallel compute my code. My code below produces an error that the Distributions and PoissonRandom packages in Julia do not exist even though the package has already been installed. My question: is it possible to run the parallel package, JuliaCall, and Julia packages?
two_part_sim_RTLs <- function(station_data){
julia_setup(JULIA_HOME = "C:/Users/Kenneth Kin Pomeyie/AppData/Local/Programs/Julia-1.6.1/bin/")
julia_library("Distributions")
julia_library("DataFrames")
julia_library("PoissonRandom")
lambda = station_data$lambda
location = station_data$location
scale = station_data$scale
shape = station_data$shape
julia_assign("lambda", lambda)
julia_assign("location", location)
julia_assign("scale", scale)
julia_assign("shape", shape)
julia_eval("x = rand(Truncated(Poisson(lambda), 0.0, 10), 50000000)")
julia_eval("load = Array{Float64}(undef, 50000000)")
julia_eval("
for i in 1:50000000
load[i] = max(rand(GeneralizedPareto(location, scale, shape)), x[i])
end
")
load = julia_eval("load")
}

plotmplier in NARDL package

I have a problem with running plotmplier command in NARDL package. I keep receiving the same error:
error in plot.window(…) :need finite ylim
erd22 <- nardl(ef~lwr,efo,ic="bic",maxlags = TRUE,graph = FALSE,case=3) summary(erd22)
plotmplier(erd22,2,2,10)
Result through NARDL in R Prog is contradicted with Stata and Eviews. F Bound test is not a correct one. Better to use Stata or eviews 9/10.

Error in expand_dims(X_train, axis = 2) : attempt to apply non-function

I tried to use keras in R to do deep learning
trend_train <- ts(global_GDP[1:28,c(3)], start=c(1981), end=c(2008))
lstm_num_timesteps <- 5
X_train <- t(sapply(1:(length(trend_train) - lstm_num_timesteps),
function(x) trend_train[x:(x + lstm_num_timesteps - 1)]))
X_train[1:5, ]
X_train <- expand_dims(X_train, axis = 2)
When try to use expand_dims(), it showed error as follows
Error in expand_dims(X_train, axis = 2) : attempt to apply non-function
Couldn't figure out what's going on here as there is no wrong with the expand_dims(). Anyone could help? Thanks
I have come across the same issue trying to build an LSTM using Keras library in R.
expand_dims() seems to be a function from kerasR library https://rdrr.io/cran/kerasR/man/expand_dims.html
If you are using keras (not kerasR package), this function is not available. This corresponding function in keras package is k_expand_dims
I also realised that this only works with keras 2.1.2. I had to upgrade from v 2.0.9 to make this work.
Hope this helps.

BoundsError in Julia MXNet when using small batch size

I'm trying to reproduce some Python MXNet code in Julia 0.6.0, and I'm getting a BoundsError if I try to use a batch size that is smaller than the dimension of the output. If I use a larger batch size in a toy example, things work properly and the network converges to the correct solution, but in my application the output dimension is large so this isn't practical.
Here's a linear regression example that gives this error:
using MXNet
net = mx.Variable(:data)
net = mx.FullyConnected(net, name=:fc0, num_hidden=5)
net = mx.LinearRegressionOutput(net, name=:output)
mod = mx.FeedForward(net, context=mx.cpu(0))
batch_size = 4 # works for batch_size > 4
A = randn(5,100)
train_in = randn(100,1000)
train_out = A*train_in + .1*randn(5,1000)
train_provider = mx.ArrayDataProvider(:data=>train_in,
:output_label=>train_out,
shuffle=true,
batch_size=batch_size)
optimizer = mx.SGD(lr=0.001, momentum=0.9, weight_decay=0.00001)
mx.fit(mod, optimizer, train_provider)
This produces
INFO: Start training on MXNet.mx.Context[CPU0]
INFO: Initializing parameters...
INFO: Creating KVStore...
INFO: TempSpace: Total 0 MB allocated on CPU0
INFO: Start training...
ERROR: LoadError: BoundsError: attempt to access 5×4 Array{Float32,2} at index [Base.Slice(Base.OneTo(5)), 5]
If I increase the batch size to 5 or greater, it works as expected. What am I missing?
You can track the resolution of this bug here:
https://github.com/dmlc/MXNet.jl/issues/264
I have tested it two weeks ago and unfortunately it is still happening.

Resources