h-klok / statswithjuliabook Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://statisticswithjulia.org/
License: MIT License
Home Page: https://statisticswithjulia.org/
License: MIT License
Use 0
in in Random.seed!()
Hi,
I tried listing 4.3 with Pluto. I ran into several bugs even after inserting the missing datatype of the sink (=DataFrame) (screenshot attached).
I succeeded with a workaround with package HTTP and HTTP.get:
http_response = HTTP.get("https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/data/purchaseData.csv")
myData = CSV.File(http_response.body)
All the best, Claus
Should be:
"h-Klok/StatsWithJuliaBook/master/data/jsonCode.json"
not
"h-Klok/StatsWithJuliaBook/master/1_chapter/jsonCode.json"
Should use Random.seed!(0)
or similar, not Random.seed!()
change the 28th line to
global state = sample(1:3,weights(P[state,:]))
will eliminate the UndefVarError: state not defined Error.
This error is due to Julia's Weird Convention for writing to a global variable.
here is a more clear explain at Stack Overflow
With 1.6.2, Win 10: MKL_jll, CUDAdrv, FFTW, HDF5, RecursiveArrayTools, CUDAnative, MAT, CuArrays, GeneralizedGenerated, Zygote, Flux, DiffEq..., ModelingToolkit, ImageFiltering, KernelDensity, StatsPlots, ... do not precompile. And that is after I removed RCall, PyCall, PyPlot manually.
C:\Users\pkonl\Documents>cd StatsWithJuliaBook-master
C:\Users\pkonl\Documents\StatsWithJuliaBook-master>..\..\AppData\Local\Programs\Julia-1.6.2\bin\julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.6.2 (2021-07-14)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> include("init.jl")
Activating environment at `C:\Users\pkonl\Documents\StatsWithJuliaBook-master\Project.toml`
(StatsWithJuliaBook-master) pkg> precompile
Precompiling project...
✗ MKL_jll
✗ CUDAdrv
✗ RecursiveArrayTools
✗ HDF5
✗ GeneralizedGenerated
✗ Zygote
✗ FFTW
✗ DiffEqBase
✗ MAT
✗ CUDAnative
✗ FFTViews
✗ KernelDensity
✗ MLDatasets
✗ Sundials
✗ BoundaryValueDiffEq
✗ DiffEqNoiseProcess
✗ DiffEqJump
✗ OrdinaryDiffEq
✗ ImageFiltering
✗ CuArrays
✗ StatsPlots
✗ ModelingToolkit
✗ DiffEqFinancial
✗ StochasticDiffEq
✗ DelayDiffEq
✗ DiffEqCallbacks
✗ ImageQualityIndexes
✗ Flux
✗ ParameterizedFunctions
✗ MultiScaleArrays
✗ Images
✗ DiffEqPhysics
✗ SteadyStateDiffEq
✗ DifferentialEquations
0 dependencies successfully precompiled in 117 seconds (229 already precompiled)
ERROR: The following 6 direct dependencies failed to precompile:
Images [916415d5-f1e6-5110-898d-aaa5f9f070e0]
Failed to precompile Images [916415d5-f1e6-5110-898d-aaa5f9f070e0] to C:\Users\pkonl\.julia\compiled\v1.6\Images\jl_3ED9.tmp.
ERROR: LoadError: FFTW is not properly installed. Please run Pkg.build("FFTW") and restart Julia.
Stacktrace:
[1] error(::String, ::String)
@ Base .\error.jl:42
[2] top-level scope
@ C:\Users\pkonl\.julia\packages\FFTW\kcXL6\src\FFTW.jl:22
[3] include
@ .\Base.jl:386 [inlined]
[4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[5] top-level scope
@ none:1
[6] eval
@ .\boot.jl:360 [inlined]
[7] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[8] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\FFTW\kcXL6\src\FFTW.jl:1
ERROR: LoadError: Failed to precompile FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341] to C:\Users\pkonl\.julia\compiled\v1.6\FFTW\jl_5C94.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\ImageFiltering\eH8Od\src\ImageFiltering.jl:1
ERROR: LoadError: Failed to precompile ImageFiltering [6a3955dd-da59-5b1f-98d4-e7296123deb5] to C:\Users\pkonl\.julia\compiled\v1.6\ImageFiltering\jl_58CB.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\Images\7IWP4\src\Images.jl:3
DifferentialEquations [0c46a032-eb83-5123-abaf-570d42b7fbaa]
Failed to precompile DifferentialEquations [0c46a032-eb83-5123-abaf-570d42b7fbaa] to C:\Users\pkonl\.julia\compiled\v1.6\DifferentialEquations\jl_7A9D.tmp.
ERROR: LoadError: LoadError: LoadError: UndefVarError: f not defined
Stacktrace:
[1] macro expansion
@ C:\Users\pkonl\.julia\packages\MacroTools\X77lQ\src\utils.jl:44 [inlined]
[2] macro expansion
@ C:\Users\pkonl\.julia\packages\MacroTools\X77lQ\src\match\macro.jl:18 [inlined]
[3] shortdef1(ex::Expr)
@ MacroTools C:\Users\pkonl\.julia\packages\MacroTools\X77lQ\src\utils.jl:240
[4] prewalk
@ C:\Users\pkonl\.julia\packages\MacroTools\X77lQ\src\utils.jl:126 [inlined]
[5] shortdef
@ C:\Users\pkonl\.julia\packages\MacroTools\X77lQ\src\utils.jl:251 [inlined]
[6] macro expansion
@ C:\Users\pkonl\.julia\packages\MacroTools\X77lQ\src\match\macro.jl:72 [inlined]
[7] gradm(ex::Expr, mut::Bool) (repeats 2 times)
@ ZygoteRules C:\Users\pkonl\.julia\packages\ZygoteRules\6nssF\src\adjoint.jl:24
[8] var"@adjoint"(__source__::LineNumberNode, __module__::Module, ex::Any)
@ ZygoteRules C:\Users\pkonl\.julia\packages\ZygoteRules\6nssF\src\adjoint.jl:63
[9] include(mod::Module, _path::String)
@ Base .\Base.jl:386
[10] include(x::String)
@ RecursiveArrayTools C:\Users\pkonl\.julia\packages\RecursiveArrayTools\GrX6g\src\RecursiveArrayTools.jl:3
[11] top-level scope
@ C:\Users\pkonl\.julia\packages\RecursiveArrayTools\GrX6g\src\RecursiveArrayTools.jl:15
[12] include
@ .\Base.jl:386 [inlined]
[13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[14] top-level scope
@ none:1
[15] eval
@ .\boot.jl:360 [inlined]
[16] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[17] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\RecursiveArrayTools\GrX6g\src\zygote.jl:1
in expression starting at C:\Users\pkonl\.julia\packages\RecursiveArrayTools\GrX6g\src\zygote.jl:1
in expression starting at C:\Users\pkonl\.julia\packages\RecursiveArrayTools\GrX6g\src\RecursiveArrayTools.jl:3
ERROR: LoadError: Failed to precompile RecursiveArrayTools [731186ca-8d62-57ce-b412-fbd966d074cd] to C:\Users\pkonl\.julia\compiled\v1.6\RecursiveArrayTools\jl_800A.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\DiffEqBase\LGnTa\src\DiffEqBase.jl:1
ERROR: LoadError: Failed to precompile DiffEqBase [2b5f629d-d688-5b77-993f-72d75c75574e] to C:\Users\pkonl\.julia\compiled\v1.6\DiffEqBase\jl_7D5A.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\DifferentialEquations\ddyFO\src\DifferentialEquations.jl:1
StatsPlots [f3b207a7-027a-5e70-b257-86293d7955fd]
Failed to precompile StatsPlots [f3b207a7-027a-5e70-b257-86293d7955fd] to C:\Users\pkonl\.julia\compiled\v1.6\StatsPlots\jl_98CB.tmp.
ERROR: LoadError: FFTW is not properly installed. Please run Pkg.build("FFTW") and restart Julia.
Stacktrace:
[1] error(::String, ::String)
@ Base .\error.jl:42
[2] top-level scope
@ C:\Users\pkonl\.julia\packages\FFTW\kcXL6\src\FFTW.jl:22
[3] include
@ .\Base.jl:386 [inlined]
[4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[5] top-level scope
@ none:1
[6] eval
@ .\boot.jl:360 [inlined]
[7] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[8] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\FFTW\kcXL6\src\FFTW.jl:1
ERROR: LoadError: Failed to precompile FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341] to C:\Users\pkonl\.julia\compiled\v1.6\FFTW\jl_DD04.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\KernelDensity\FYY3d\src\KernelDensity.jl:1
ERROR: LoadError: Failed to precompile KernelDensity [5ab0869b-81aa-558d-bb23-cbf5423bbe9b] to C:\Users\pkonl\.julia\compiled\v1.6\KernelDensity\jl_C853.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\StatsPlots\sVXzR\src\StatsPlots.jl:1
Flux [587475ba-b771-5e3f-ad9e-33799f191a9c]
Failed to precompile Flux [587475ba-b771-5e3f-ad9e-33799f191a9c] to C:\Users\pkonl\.julia\compiled\v1.6\Flux\jl_1C0C.tmp.
ERROR: LoadError: LoadError: LoadError: UndefVarError: __source__ not defined
Stacktrace:
[1] var"@nograd"(__source__::LineNumberNode, __module__::Module, ex::Any)
@ Zygote C:\Users\pkonl\.julia\packages\Zygote\z3bQd\src\lib\grad.jl:7
[2] include(mod::Module, _path::String)
@ Base .\Base.jl:386
[3] include(x::String)
@ Zygote C:\Users\pkonl\.julia\packages\Zygote\z3bQd\src\Zygote.jl:1
[4] top-level scope
@ C:\Users\pkonl\.julia\packages\Zygote\z3bQd\src\Zygote.jl:26
[5] include
@ .\Base.jl:386 [inlined]
[6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[7] top-level scope
@ none:1
[8] eval
@ .\boot.jl:360 [inlined]
[9] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[10] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\Zygote\z3bQd\src\lib\lib.jl:30
in expression starting at C:\Users\pkonl\.julia\packages\Zygote\z3bQd\src\lib\lib.jl:30
in expression starting at C:\Users\pkonl\.julia\packages\Zygote\z3bQd\src\Zygote.jl:1
ERROR: LoadError: Failed to precompile Zygote [e88e6eb3-aa80-5325-afca-941959d7151f] to C:\Users\pkonl\.julia\compiled\v1.6\Zygote\jl_1EEF.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\Flux\Fj3bt\src\Flux.jl:1
KernelDensity [5ab0869b-81aa-558d-bb23-cbf5423bbe9b]
Failed to precompile KernelDensity [5ab0869b-81aa-558d-bb23-cbf5423bbe9b] to C:\Users\pkonl\.julia\compiled\v1.6\KernelDensity\jl_11FE.tmp.
ERROR: LoadError: FFTW is not properly installed. Please run Pkg.build("FFTW") and restart Julia.
Stacktrace:
[1] error(::String, ::String)
@ Base .\error.jl:42
[2] top-level scope
@ C:\Users\pkonl\.julia\packages\FFTW\kcXL6\src\FFTW.jl:22
[3] include
@ .\Base.jl:386 [inlined]
[4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[5] top-level scope
@ none:1
[6] eval
@ .\boot.jl:360 [inlined]
[7] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[8] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\FFTW\kcXL6\src\FFTW.jl:1
ERROR: LoadError: Failed to precompile FFTW [7a1cc6ca-52ef-59f5-83cd-3a7055c09341] to C:\Users\pkonl\.julia\compiled\v1.6\FFTW\jl_2B57.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\KernelDensity\FYY3d\src\KernelDensity.jl:1
MLDatasets [eb30cadb-4394-5ae3-aed4-317e484a6458]
Failed to precompile MLDatasets [eb30cadb-4394-5ae3-aed4-317e484a6458] to C:\Users\pkonl\.julia\compiled\v1.6\MLDatasets\jl_28C3.tmp.
ERROR: LoadError: HDF5 is not properly installed. Please run Pkg.build("HDF5") and restart Julia.
Stacktrace:
[1] error(::String, ::String)
@ Base .\error.jl:42
[2] top-level scope
@ C:\Users\pkonl\.julia\packages\HDF5\pAi1D\src\HDF5.jl:31
[3] include
@ .\Base.jl:386 [inlined]
[4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[5] top-level scope
@ none:1
[6] eval
@ .\boot.jl:360 [inlined]
[7] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[8] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\HDF5\pAi1D\src\HDF5.jl:1
ERROR: LoadError: Failed to precompile HDF5 [f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f] to C:\Users\pkonl\.julia\compiled\v1.6\HDF5\jl_3F3D.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:386 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\MAT\2LFMT\src\MAT.jl:25
ERROR: LoadError: LoadError: Failed to precompile MAT [23992714-dd62-5051-b70f-ba57cb901cac] to C:\Users\pkonl\.julia\compiled\v1.6\MAT\jl_3BD2.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include(mod::Module, _path::String)
@ Base .\Base.jl:386
[8] include(x::String)
@ MLDatasets C:\Users\pkonl\.julia\packages\MLDatasets\aov6i\src\MLDatasets.jl:1
[9] top-level scope
@ C:\Users\pkonl\.julia\packages\MLDatasets\aov6i\src\MLDatasets.jl:35
[10] include
@ .\Base.jl:386 [inlined]
[11] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[12] top-level scope
@ none:1
[13] eval
@ .\boot.jl:360 [inlined]
[14] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[15] top-level scope
@ none:1
in expression starting at C:\Users\pkonl\.julia\packages\MLDatasets\aov6i\src\SVHN2\SVHN2.jl:3
in expression starting at C:\Users\pkonl\.julia\packages\MLDatasets\aov6i\src\MLDatasets.jl:1
(StatsWithJuliaBook-master) pkg>
On page 17 of the pdf file, the root of the function should actually be -0.2 and 0.5 .
in takes and event as an input
, and
-> an
Not sure this is the good place to provide corrections. Anyway :
The web address to get the json file is
https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/data/jsonCode.json
(data instead of 1_chapter)
When parsing the resulting body, I had to chomp the string as follows :
parsedJsonDict = JSON.parse(chomp(String(jsonWords.body)))
Thanks.
Hello. Thanks for writing the book, I'm enjoying reading it.
In Listing 2.4 (which corresponds to 2_chapter/fishing.jl), the plot!
calls do not create the expected chart.
Adding the named parameter xlims=(-0.5,4)
to the plot!
function calls creates the expected output.
It can
canbe downloaded directly from: https://julialang.org/downloads/.
Hi,
Over the last few months I have been working on a new version of StatisticalRethinking (v3) and one part that I always found lacking is a good introduction to statistics using Julia. Your upcoming book fills this gap very nicely (and more). As the upcoming StatisticalRethinking v3 will use projects, Pluto notebooks and Plots (GR) I wanted to use a similar setup for your book's listings. As a proof of concept I did 3 chapters in StatisticsWithJuliaPlutoNotebooks.
My question is if this usage would be ok with both of you.
This is just a project, there is no need to register it, and if you are not ok I can make the repository private and remove all links to it in StatisticalRethinking.jl. Or, in case you would choose at some point to make (these or another version of the) Pluto notebooks part of your github repository I would simply update the links accordingly.
Thanks for a great book and your time to consider my request,
Rob
cc.: @yoninazarathy, @h-Klok
Hi. Many thanks for the book! I'm really grateful for this.
On this particular example, the following code is quite inefficient (uses >1GB memory and takes >1.5 secs for n=5) - even on the 2nd pass after compilation. It also fails (insufficient memory etc) pretty quickly as n increases.
omega = unique(permutations([zeros(Int,n);ones(Int,n)]))
Something better would be to use the combinations function instead to get (2n,n) places, and populate them with 1s etc. The following runs easily 2 orders of magnitude faster (on the 2nd pass once compiled):
function seqToPath(seq, n)
path = zeros(Int8, 2n)
[path[i] = 1 for i in seq]
return path
end
X = combinations(1:2n, n) |> collect
omega = map(s -> seqToPath(s, n), X)
This takes < 0.04s for n=5, and <5MB memory. This code finishes in <0.2s for n=10 as well.
Thanks for great code samples, and sorry for another issue. (I'll post one more later.)
Your repo is contaminated with carriage return ^M
. Please check your core.autocrlf
settings so that git diff
would produce consistent behavior across OS. GitHub's guide for line endings would be helpful.
Here's a list of files contaminated with ^M
:
$ git grep -l "^M"
1_chapter/imageProcessing.jl
3_chapter/basicDistRand.jl
3_chapter/gammafunctionIntegration.jl
3_chapter/inverseCDF.jl
3_chapter/mvParams.jl
3_chapter/normalCalculus.jl
3_chapter/weibullHazard.jl
4_chapter/dataframeReferencing.jl
5_chapter/centralLimitTheorem.jl
5_chapter/randomizationTest.jl
data/IQalc.csv
data/L1L2data.csv
data/examData.csv
data/fertilizer.csv
data/grades.csv
data/jsonCode.json
data/machine3.csv
data/stars.png
data/temperatures.csv
data/weightHeight.csv
To verify my claim, you may pick any file listed above and use curl
to display the remote file to STDOUT, then pipe it to od -c
for display with printable characters or backslash escapes.
$ curl -L https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/data/fertilizer.csv | od -c
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 128 100 128 0 0 184 0 --:--:-- --:--:-- --:--:-- 184
0000000 C o n t r o l , F e r t i l i z
0000020 e r X \r \n 4 . 1 7 , 6 . 3 1 \r \n
0000040 5 . 5 8 , 5 . 1 2 \r \n 5 . 1 8 ,
0000060 5 . 5 4 \r \n 6 . 1 1 , 5 . 5 \r \n
0000100 4 . 5 , 5 . 3 7 \r \n 4 . 6 1 , 5
0000120 . 2 9 \r \n 5 . 1 7 , 4 . 9 2 \r \n
0000140 4 . 5 3 , 6 . 1 5 \r \n 5 . 3 3 ,
0000160 5 . 8 \r \n 5 . 1 4 , 5 . 2 6 \r \n
0000200
The \r \n
in od -c
's output represents carriage returns ^M
that you've committed on Windows. That would creat a trailing ^M
in git diff
's output on GNU/Linux.
In addition, some text files don't have trailing newline \n
at the end of file (EOF). That would cause inconsistent results with some command line utilities such as wc
on GNU/LInux. You may refer to Why should text files end with a newline? on Stack Overflow to know more.
In Listing 7.4, change n
to n=20
and changed cdf
of Binomial to ccdf
. Thank you to Ali Araghian.
using Random, Statistics
Random.seed!(0)
include("dataframeCreation.jl")
filter!(purchaseData) do row
!(ismissing(row.Type) && ismissing(row.Price))
end
got errors :
MethodError: no method matching deleteat!(::CSV.Column{Union{Missing, String},Union{Missing, String}}, ::Array{Int64,1})
import DataFrames, GLM, PyPlot , Statistics, CSV
data = CSV.read("../data/weightHeight.csv")
lm1 = lm(@formula(Height ~ Weight), data)
when running this piece of code , I found an error with "UndefVarError: @formula not defined"
julia version : 1.1.1
I wonder if it is a good idea to have a minimum requirement of a recent Julia version in the Project.toml.
The README has Julia 1.4, but perhaps it should be bumped to 1.5, and 1.6 when that releases - mainly for the reductions in package loading times.
Add random seed.
Should have abs value of tSTat
in line 9. Thanks to Dietmar Oelz.
I got:
(@v1.5) pkg> add https://github.com/h-Klok/StatsWithJuliaBook
Cloning git-repo `https://github.com/h-Klok/StatsWithJuliaBook`
Updating git-repo `https://github.com/h-Klok/StatsWithJuliaBook`
ERROR: expected a `name` entry in project file at `/var/folders/rj/njz8jnv11637flz6vgnb6bz00000gp/T/jl_mQRFNN/Project.toml
I can't see the edges in graph.jl
in 1_chapter.
I tried to run the file both with Atom Juno and Jupyter Lab.
Listing 4.5 contains the following
using DataFrames, CSV
data1 = CSV.read("../data/purchaseData.csv")
data2 = CSV.read("../data/purchaseData.csv", copycols=true)
However, CSV v0.8.4 requires an extra argument DataFrame. And using copycols
does not seem to have any effect.
I am using Julia 1.6.1 and DataFrames v1.1.1
I really like your book but I personally prefer using Julia plotting packages instead of the pyplot.
It seems your repo assumes that the user has python and R installed. If that is the case, it should be spelled out explicitly in the instructions. Without those two the activation/instantiation runs into trouble and the user is left with the task of figuring out what went wrong. It is "with Julia" after all, not "with Julia, and Python, and R". ;-)
Thanks for your excellent work. I plan to cite this project and the related book into a talk and tutorial. I write a Bibtex and think it is helpful for other users who have the same purpose as me.
@online{Klok2019,
author = {Hayden Klok and Yoni Nazarathy},
title = {Statistics with Julia},
subtitle = {Fundamentals for Data Science, Machine Learning and Artificial Intelligence.},
year = 2019,
url = {https://people.smp.uq.edu.au/YoniNazarathy/julia-stats/StatisticsWithJulia.pdf},
urldate = {2019-07-14}
}
When running plotSimple.jl
I get several warnings like this one (that I don't understand completely):
┌ Warning: `getindex(o::PyObject, s::Symbol)` is deprecated in favor of dot overloading (`getproperty`) so elements should now be accessed as e.g. `o.s` instead of `o[:s]`.
│ caller = top-level scope at In[1]:8
└ @ Core In[1]:8
Hello,
Thank so much for your work!
I think there is a typo in eq 5.3, the third nonzero case of the joint PMF of \bar{X} and S^2 should be "$\bar{x} = 1$ and
I was trying to run usingR.jl
from 1_chapter
but it was needed to define previously a path to data
folder to access machine*.csv
files.
Thanks for your great book. I wished that it had appeared two years ago.
To learn programming in Julia, the most efficient way is to get my hands dirty and play with existing code. As a result, I've created a fork on Framagit for personal learning a few weeks ago. That would mean that I'm "redistribuing modified versions" of your code.
Having a license for your code would allow others to choose the optimal way of storing the cloned Git repo for this project.
In section 1.1:
...while the functions subtype() and supertype() return the subtype and supertype of a particular type respectively...
I believe the correct function name is subtypes() <-- plural
First of all, thanks for this amazing resource. I hope you could finish this book.
For the issue, I don't know if this is the right kind of issue to be reported here but I did download the draft and I use Adobe Acrobat to read it. The problem is it freezes like every 2 mins while scrolling through pages. I have no problems with other files that has the same size or has been written in LaTex and then converted to pdf.
Is there any chance that the problem caused by the draft?
When showing the ODEs, SDEs, and discrete event simulation, it would be nice to showcase how to use the packages, since writing out Euler methods and using Kalman filters really doesn't scale. This would make it useful to the wider community of engineers.
The URL for the jsonCode.json file in the draft is: https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/1_chapter/jsonCode.json However, the correct URL is: https://raw.githubusercontent.com/h-Klok/StatsWithJuliaBook/master/data/jsonCode.json
The macro @pyimport
appears many times in this project. Unluckily, it's deprecated due to JuliaPy/PyCall.jl#633.
I'm working on #10 to get rid of this.
Hi Team - I am really loving the book - thanks so much for writing it.
I am receiving a consistent error in the Chapter 2 Birthday problem scatter plot:
MethodError: no method matching Val{:scatter}(::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char)
apply_recipe(plotattributes::Dict{Symbol, Any}, #unused#::Type{Val{:scatter}}, plt::Plots.Plot{Plots.PyPlotBackend}) at recipes.jl:50
_process_plotrecipe(plt::Any, kw::Any, kw_list::Any, still_to_process::Any) at plot_recipe.jl:32
_process_plotrecipes!(plt::Any, kw_list::Any) at plot_recipe.jl:18
recipe_pipeline!(plt::Any, plotattributes::Any, args::Any) at RecipesPipeline.jl:81
_plot!(plt::Plots.Plot, plotattributes::Any, args::Any) at plot.jl:172
plot!(::Plots.Plot, ::Any, ::Vararg{Any, N} where N; kw::Any) at plot.jl:162
(::RecipesBase.var"#plot!##kw")(::NamedTuple{(:c, :ms, :msw, :shape, :label, :xlims, :ylims, :xlabel, :ylabel, :legend, :seriestype), Tuple{Symbol, Int64, Int64, Symbol, String, Tuple{Int64, Int64}, Tuple{Int64, Int64}, String, String, Symbol, Symbol}}, ::typeof(plot!), ::Plots.Plot{Plots.PyPlotBackend}, ::UnitRange{Int64}, ::Vararg{Any, N} where N) at plot.jl:159
plot!(::Any, ::Vararg{Any, N} where N; kw::Any) at plot.jl:153
(::RecipesBase.var"#plot!##kw")(::NamedTuple{(:c, :ms, :msw, :shape, :label, :xlims, :ylims, :xlabel, :ylabel, :legend, :seriestype), Tuple{Symbol, Int64, Int64, Symbol, String, Tuple{Int64, Int64}, Tuple{Int64, Int64}, String, String, Symbol, Symbol}}, ::typeof(plot!), ::UnitRange{Int64}, ::Vector{Float64}) at plot.jl:147
scatter!(::Any, ::Vararg{Any, N} where N; kw::Any) at RecipesBase.jl:405
(::Plots.var"#scatter!##kw")(::Any, ::typeof(scatter!), ::Any, ::Vararg{Any, N} where N) at RecipesBase.jl:405
top-level scope at Week 1.jl:271
eval at boot.jl:360 [inlined]
I have tried the ocde in Juno, Jupyter and Pluto - same error.
I am unsure whether there have been updates to packages or dependencies, etc. that are causing this.
The code I have implemented is below.
import Pkg; Pkg.add("Combinatorics")
import Pkg; Pkg.add("PyPlot")
using StatsBase, Combinatorics, Plots ; pyplot()
matchExists1(n) = 1 - prod([k/365 for k in 365:-1:365-n+1])
matchExists2(n) = 1- factorial(365,365-big(n))/365^big(n)
function bdEvent(n)
birthdays = rand(1:365,n)
dayCounts = counts(birthdays, 1:365)
return maximum(dayCounts) > 1
end
probEst(n) = sum([bdEvent(n) for _ in 1:N])/N
xGrid = 1:50
analyticSolution1 = [matchExists1(n) for n in xGrid]
analyticSolution2 = [matchExists2(n) for n in xGrid]
println("Maximum error: $(maximum(abs.(analyticSolution1 - analyticSolution2)))")
N = 10^3
mcEstimates = [probEst(n) for n in xGrid]
plot(xGrid, analyticSolution1, c=:blue, label="Analytic solution")
scatter!(xGrid, mcEstimates, c=:red, ms=6, msw=0, shape=:xcross,
label="MC estimate", xlims=(0,50), ylims=(0, 1),
xlabel="Number of people in room",
ylabel="Probability of birthday match",
legend=:topleft)
If you commit the project and manifest files in version control, you'll have a perfect record of your entire Julia dependency graph for each project.
--- Is any way to install multiple versions of same package? on Julia Discourse by StefanKarpinski
These TOML files would tell us the version of packages used in this book. They will facilitate the debug process and discussions in case of bugs/warnings, say in #4.
julia> # press `]` to activate the package REPL mode...
(v1.1) pkg> activate .
(Project1) pkg> add {package-name}@{version-number}
Cross-posted at https://discourse.julialang.org/t/csv-read-deprecated-keyword-argument/24095?u=vincenttam
These three lines of code
StatsWithJuliaBook/1_chapter/usingR.jl
Lines 3 to 5 in 0369445
gives the following warning.
┌ Warning: `allowmissing` is a deprecated keyword argument
└ @ CSV ~/.julia/packages/CSV/MKiwM/src/CSV.jl:157
┌ Warning: `allowmissing` is a deprecated keyword argument
└ @ CSV ~/.julia/packages/CSV/MKiwM/src/CSV.jl:157
┌ Warning: `allowmissing` is a deprecated keyword argument
└ @ CSV ~/.julia/packages/CSV/MKiwM/src/CSV.jl:157
R ANOVA f-value: 10.516968568709089
R ANOVA p-value: 0.00014236168817139574
I've committed a382d59 to implement the suggestions received in the linked thread.
julia> println("Manual ANOVA: ", manualANOVA([data1, data2, data3]))
Manual ANOVA: (10.516968568709117, 0.00014236168817139249)
julia> println("GLM ANOVA: ", glmANOVA([data1, data2, data3]))
GLM ANOVA: (NaN, NaN)
julia>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.