# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=95

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 96

---

## [Optimizing a simple random walk simulation](https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653)

<div class="topic-metadata">

**Author:** [@aris](https://discourse.julialang.org/u/aris)\
**Replies:** 41\
**Last updated:** [January 13, 2025, 10:49am UTC](https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653 "2025-01-13T10:49:45Z")

</div>

Hello everyone, Suppose we have a simple random walk simulation, where a collection of walkers take a step towards a random direction at each time step. For each walker at each step, if some condition is met, the walker…

---

## [Understanding compilation with Optim.jl and OrdinaryDiffEq.jl](https://discourse.julialang.org/t/understanding-compilation-with-optim-jl-and-ordinarydiffeq-jl/124566)

<div class="topic-metadata">

**Author:** [@ysfoo](https://discourse.julialang.org/u/ysfoo)\
**Replies:** 7\
**Last updated:** [January 13, 2025, 8:05am UTC](https://discourse.julialang.org/t/understanding-compilation-with-optim-jl-and-ordinarydiffeq-jl/124566 "2025-01-13T08:05:54Z")

</div>

I’m currently working on numerical optimisation problems that involve solving ODEs, similar to this. I’m trying to understand recurring TTFX when I repeatedly run variations of numerical optimisation problems. Here’s th…

---

## [Using \`@overlay\` like Cassette.jl?](https://discourse.julialang.org/t/using-overlay-like-cassette-jl/124700)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 2\
**Last updated:** [January 12, 2025, 8:54pm UTC](https://discourse.julialang.org/t/using-overlay-like-cassette-jl/124700 "2025-01-12T20:54:39Z")

</div>

I was wondering if anybody knew if it is possible to use Base.Experimental.@overlay in a way similar the overdubbing feature of Cassette.jl? In particular, I want to override the behavior of every single function compile…

---

## [Need help: precompilation terminates Julia](https://discourse.julialang.org/t/need-help-precompilation-terminates-julia/124685)

<div class="topic-metadata">

**Author:** [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Replies:** 1\
**Last updated:** [January 12, 2025, 6:57pm UTC](https://discourse.julialang.org/t/need-help-precompilation-terminates-julia/124685 "2025-01-12T18:57:27Z")

</div>

I recently added a branch to PSSFSS.jl to add a new feature and saw that CI was failing. PSSFSS would no longer compile due to failure to compile one of its dependencies, TicraUtilities.jl, another one of my packages th…

---

## [Parametric type with \`@ccall\` compiler bug?](https://discourse.julialang.org/t/parametric-type-with-ccall-compiler-bug/124688)

<div class="topic-metadata">

**Author:** [@mattsignorelli](https://discourse.julialang.org/u/mattsignorelli)\
**Replies:** 10\
**Last updated:** [January 12, 2025, 5:44pm UTC](https://discourse.julialang.org/t/parametric-type-with-ccall-compiler-bug/124688 "2025-01-12T17:44:09Z")

</div>

TL;DR: # The following works fine: mt = MyType{Int32,CTable(16)}() # Define convenience ctor: MyType{T}() where {T} = MyType{T,CTable(16)}() # This throws a weird error: MType{Int32}() I maintain a Julia interface to…

---

## [Need better message for background-task precompilation error](https://discourse.julialang.org/t/need-better-message-for-background-task-precompilation-error/124701)

<div class="topic-metadata">

**Author:** [@Bradley\_Kuszmaul](https://discourse.julialang.org/u/Bradley_Kuszmaul)\
**Replies:** 0\
**Last updated:** [January 12, 2025, 4:30pm UTC](https://discourse.julialang.org/t/need-better-message-for-background-task-precompilation-error/124701 "2025-01-12T16:30:06Z")

</div>

I was seeing the following warning when I did using StorageIntegration (a package I was developing): StorageIntegration Waiting for background task / IO / timer. \[pid 36551\] waiting for IO to finish: Handle type …

---

## [Blacklisting a type from being captured in functions](https://discourse.julialang.org/t/blacklisting-a-type-from-being-captured-in-functions/124684)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 12\
**Last updated:** [January 12, 2025, 3:42pm UTC](https://discourse.julialang.org/t/blacklisting-a-type-from-being-captured-in-functions/124684 "2025-01-12T15:42:25Z")

</div>

In support of BorrowChecker.jl I am trying to figure out if there’s a way I can throw an error if an instance of a particular type gets captured in a function. For example, if I have a type struct NoCapture{T} x::T…

---

## [Using Multivariate Posterior Samples as Prior in Julia’s Turing for MCMC](https://discourse.julialang.org/t/using-multivariate-posterior-samples-as-prior-in-julia-s-turing-for-mcmc/124698)

<div class="topic-metadata">

**Author:** [@hinata235](https://discourse.julialang.org/u/hinata235)\
**Replies:** 0\
**Last updated:** [January 12, 2025, 2:59pm UTC](https://discourse.julialang.org/t/using-multivariate-posterior-samples-as-prior-in-julia-s-turing-for-mcmc/124698 "2025-01-12T14:59:11Z")

</div>

Question: I would like to use posterior distribution samples obtained via MCMC for multivariate parameters of a certain model as the prior distribution when running MCMC on another dataset. Currently, for the univariat…

---

## [How to Use a Distribution Estimated via Kernel Density Estimation (KDE) as a Prior in Turing.jl](https://discourse.julialang.org/t/how-to-use-a-distribution-estimated-via-kernel-density-estimation-kde-as-a-prior-in-turing-jl/124504)

<div class="topic-metadata">

**Author:** [@hinata235](https://discourse.julialang.org/u/hinata235)\
**Replies:** 4\
**Last updated:** [January 12, 2025, 2:02pm UTC](https://discourse.julialang.org/t/how-to-use-a-distribution-estimated-via-kernel-density-estimation-kde-as-a-prior-in-turing-jl/124504 "2025-01-12T14:02:49Z")

</div>

Background and Goal I have a set of discrete samples (e.g., from some existing dataset or posterior). I estimated a continuous distribution from these samples using a kernel density estimation (KDE) approach (such as vi…

---

## [JLD and package extensions](https://discourse.julialang.org/t/jld-and-package-extensions/124656)

<div class="topic-metadata">

**Author:** [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Replies:** 2\
**Last updated:** [January 12, 2025, 8:05am UTC](https://discourse.julialang.org/t/jld-and-package-extensions/124656 "2025-01-12T08:05:46Z")

</div>

I would like to make a package extension that loads if JLD.jl is loaded. I got the code below to work in the REPL, but when I make Abc the main package and JLDExt the extension (and remove the dots in front of the packag…

---

## [In-place broadcasting for a specific function](https://discourse.julialang.org/t/in-place-broadcasting-for-a-specific-function/124680)

<div class="topic-metadata">

**Author:** [@arnaud-ma](https://discourse.julialang.org/u/arnaud-ma)\
**Replies:** 8\
**Last updated:** [January 12, 2025, 3:40am UTC](https://discourse.julialang.org/t/in-place-broadcasting-for-a-specific-function/124680 "2025-01-12T03:40:03Z")

</div>

My code is as follows: function get\_foo(x, y, args...) # specific algorithm that modifies x and y... return x + y end function gen\_foo!(A::AbstractMatrix, args...) # is equivalent to: for coord in Carte…

---

## [Why are concatenated String15's promoted to String31?](https://discourse.julialang.org/t/why-are-concatenated-string15s-promoted-to-string31/124686)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 2\
**Last updated:** [January 12, 2025, 12:27am UTC](https://discourse.julialang.org/t/why-are-concatenated-string15s-promoted-to-string31/124686 "2025-01-12T00:27:11Z")

</div>

I found this bug (I guess it is mine) when trying to @reset an element of an SVector{String15} after updating Accessors from 0.1.38 to 0.1.39, but not sure why it used to work. MWE: julia\> using InlineStrings julia\> x…

---

## [Unexpected struct size on aarch64 (macOS M)](https://discourse.julialang.org/t/unexpected-struct-size-on-aarch64-macos-m/124608)

<div class="topic-metadata">

**Author:** [@Cees\_de\_Groot](https://discourse.julialang.org/u/Cees_de_Groot)\
**Replies:** 4\
**Last updated:** [January 11, 2025, 11:06pm UTC](https://discourse.julialang.org/t/unexpected-struct-size-on-aarch64-macos-m/124608 "2025-01-11T23:06:40Z")

</div>

(see also Startup issue on recent macOS on M3 · Issue #29 · felipenoris/Oracle.jl · GitHub) We’d like to use Oracle.jl for a project and the initial port went fine, until someone wanted to run things on their macbook. T…

---

## [SQL and Macros](https://discourse.julialang.org/t/sql-and-macros/124673)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 1\
**Last updated:** [January 11, 2025, 3:59pm UTC](https://discourse.julialang.org/t/sql-and-macros/124673 "2025-01-11T15:59:21Z")

</div>

I have the following script that runs fine: using DuckDB using DBInterface using DataFrames # Global connection variable for reuse const duckdb\_connection = Ref{Union{DuckDB.DB, Nothing}}(nothing) # Function to manage…

---

## [Determine whether a project has been instantiated](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 6\
**Last updated:** [January 11, 2025, 3:22pm UTC](https://discourse.julialang.org/t/determine-whether-a-project-has-been-instantiated/124652 "2025-01-11T15:22:55Z")

</div>

Is it possible to determine whether a given folder containing a Julia project has been instantiated? The folder is unrelated to the julia process where I want to do this, i.e., I’m not trying to figure out whether the cu…

---

## [Unexpected broadcasting behaviour (?)](https://discourse.julialang.org/t/unexpected-broadcasting-behaviour/124670)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 2\
**Last updated:** [January 11, 2025, 12:36pm UTC](https://discourse.julialang.org/t/unexpected-broadcasting-behaviour/124670 "2025-01-11T12:36:57Z")

</div>

Hi I was wondering if the MWE below yields the expected behaviour. Why is the result not symmetric? I would have expected symmetric resulting arrays sizes from this. Cheers! let b = ones(3, 4) a = ones(1, 2…

---

## [Product of probability distribution and nonrandom function](https://discourse.julialang.org/t/product-of-probability-distribution-and-nonrandom-function/124622)

<div class="topic-metadata">

**Author:** [@rand5](https://discourse.julialang.org/u/rand5)\
**Replies:** 0\
**Last updated:** [January 10, 2025, 4:49am UTC](https://discourse.julialang.org/t/product-of-probability-distribution-and-nonrandom-function/124622 "2025-01-10T04:49:40Z")

</div>

I have a probability distribution, e.g. Y = Normal() and would like to scale the distribution (updating its pdf, cdf, etc.) by a nonrandom function, say f(x) = cdf(Normal(1,2),x). Is there a way to do this and have the …

---

## [Weird problem. Two runs of the same code and the second run takes forever and gobbles up memory](https://discourse.julialang.org/t/weird-problem-two-runs-of-the-same-code-and-the-second-run-takes-forever-and-gobbles-up-memory/124654)

<div class="topic-metadata">

**Author:** [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Replies:** 4\
**Last updated:** [January 11, 2025, 7:07am UTC](https://discourse.julialang.org/t/weird-problem-two-runs-of-the-same-code-and-the-second-run-takes-forever-and-gobbles-up-memory/124654 "2025-01-11T07:07:58Z")

</div>

I’m facing a weird problem and I have no clue where to start looking. I’m running some economic simulations and since I made the agent creation type safe (eliminated the warning that the types of the agent were not defi…

---

## [Memory Errors at Julia-C interface and Safe Pointer Usage](https://discourse.julialang.org/t/memory-errors-at-julia-c-interface-and-safe-pointer-usage/124484)

<div class="topic-metadata">

**Author:** [@luke-kiernan](https://discourse.julialang.org/u/luke-kiernan)\
**Replies:** 13\
**Last updated:** [January 10, 2025, 11:27pm UTC](https://discourse.julialang.org/t/memory-errors-at-julia-c-interface-and-safe-pointer-usage/124484 "2025-01-10T23:27:09Z")

</div>

I have a snippet of code that runs just fine in C, but when I try to make the same code work in Julia, I get memory errors: either Illegal instruction or Segmentation fault. It’s a part of a larger project, creating a Ju…

---

## [Reverse dependencies of a package?](https://discourse.julialang.org/t/reverse-dependencies-of-a-package/9774)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 11\
**Last updated:** [January 10, 2025, 11:31pm UTC](https://discourse.julialang.org/t/reverse-dependencies-of-a-package/9774 "2025-01-10T23:31:49Z")

</div>

Are there existing tools for evaluating the reverse dependencies of a package? That is, for determining the packages that depend directly or indirectly on a particular package? It occurred to me that, if not, this migh…

---

## [Package for Rust-like borrow checker in Julia?](https://discourse.julialang.org/t/package-for-rust-like-borrow-checker-in-julia/124442)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 87\
**Last updated:** [January 10, 2025, 7:20pm UTC](https://discourse.julialang.org/t/package-for-rust-like-borrow-checker-in-julia/124442 "2025-01-10T19:20:16Z")

</div>

My least favorite bugs are usually caused by: Thread races Aliased memory While Rust doesn’t fill the same niche as Julia with respect to scientific computing, I really like the safety guarantees around ownership and …

---

## [Policy function algorithm becomes much slower when I increase the upper bound of the grid](https://discourse.julialang.org/t/policy-function-algorithm-becomes-much-slower-when-i-increase-the-upper-bound-of-the-grid/124536)

<div class="topic-metadata">

**Author:** [@SGHoekstra](https://discourse.julialang.org/u/SGHoekstra)\
**Replies:** 4\
**Last updated:** [January 10, 2025, 5:03pm UTC](https://discourse.julialang.org/t/policy-function-algorithm-becomes-much-slower-when-i-increase-the-upper-bound-of-the-grid/124536 "2025-01-10T17:03:58Z")

</div>

Dear all, I am facing a performance issue that I find hard to understand so I am hoping I can gain some insights here. I have written code to solve an economic problem using fixed point iteration or also known as policy…

---

## [Memory Allocation in \`@time\` but not in \`AllocCheck.check\_allocs\`](https://discourse.julialang.org/t/memory-allocation-in-time-but-not-in-alloccheck-check-allocs/124638)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [January 10, 2025, 3:28pm UTC](https://discourse.julialang.org/t/memory-allocation-in-time-but-not-in-alloccheck-check-allocs/124638 "2025-01-10T15:28:43Z")

</div>

Hi there, I am wondering what this is about: In @time I see an allocation of 16 Bytes. When using AllocCheck.check\_allocs, everything is clean. Here a code example: using Statistics using LinearAlgebra using StaticAr…

---

## [Struct containing a dictionary of cache buffers?](https://discourse.julialang.org/t/struct-containing-a-dictionary-of-cache-buffers/124643)

<div class="topic-metadata">

**Author:** [@cocoa1231](https://discourse.julialang.org/u/cocoa1231)\
**Replies:** 1\
**Last updated:** [January 10, 2025, 2:52pm UTC](https://discourse.julialang.org/t/struct-containing-a-dictionary-of-cache-buffers/124643 "2025-01-10T14:52:45Z")

</div>

I want to have a few buffers and/or dicts that serve as caches for various methods I’m implementing on my struct. This struct will basically be alive for the lifetime of the program as it’s a wrapper containing informati…

---

## [Viewer of matrix in VS Code](https://discourse.julialang.org/t/viewer-of-matrix-in-vs-code/105369)

<div class="topic-metadata">

**Author:** [@Sergey\_Novak](https://discourse.julialang.org/u/Sergey_Novak)\
**Replies:** 6\
**Last updated:** [January 10, 2025, 2:32pm UTC](https://discourse.julialang.org/t/viewer-of-matrix-in-vs-code/105369 "2025-01-10T14:32:28Z")

</div>

Hello! Is there a way to view a multidimensional matrix like in environment spyder? For example, I have a NxNx2 matrix and I would like to present it in a similar form, where each cell would contain two elements

---

## [StaticArrays solve symmetric linear system - seems typeinstable](https://discourse.julialang.org/t/staticarrays-solve-symmetric-linear-system-seems-typeinstable/124634)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [January 10, 2025, 2:25pm UTC](https://discourse.julialang.org/t/staticarrays-solve-symmetric-linear-system-seems-typeinstable/124634 "2025-01-10T14:25:03Z")

</div>

Hi there, I am wondering why the following does not return a SVector, but allocates a normal Vector. Also warntype shows problems using StaticArrays using LinearAlgebra using Statistics function testme(xs=rand(20)) …

---

## [Convolution of Dependent Random Variables with Copula](https://discourse.julialang.org/t/convolution-of-dependent-random-variables-with-copula/124603)

<div class="topic-metadata">

**Author:** [@rand5](https://discourse.julialang.org/u/rand5)\
**Replies:** 3\
**Last updated:** [January 10, 2025, 1:45pm UTC](https://discourse.julialang.org/t/convolution-of-dependent-random-variables-with-copula/124603 "2025-01-10T13:45:05Z")

</div>

I’m running into domain issues when trying to compute the convolution of two random variables where their joint distribution is defined by a copula. By convolution I mean: f\_{Z}(z) = \\int\_{-\\inf}^{\\inf} f\_{XY}(x,z-x)dx…

---

## [Unit test for constant folding success](https://discourse.julialang.org/t/unit-test-for-constant-folding-success/124625)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 6\
**Last updated:** [January 10, 2025, 11:02am UTC](https://discourse.julialang.org/t/unit-test-for-constant-folding-success/124625 "2025-01-10T11:02:52Z")

</div>

Here’s a proposal for how to test for successful constant folding: using Test function test\_constant\_folding(f, r) vec = code\_typed(f, Tuple{}) p = only(vec) code\_info = first(p) code = try code…

---

## [The Unreasonable Efficiency and Effectiveness of Multiple Dispatch: Your Favourite Examples](https://discourse.julialang.org/t/the-unreasonable-efficiency-and-effectiveness-of-multiple-dispatch-your-favourite-examples/119477)

<div class="topic-metadata">

**Author:** [@kapple](https://discourse.julialang.org/u/kapple)\
**Replies:** 36\
**Last updated:** [January 10, 2025, 9:38am UTC](https://discourse.julialang.org/t/the-unreasonable-efficiency-and-effectiveness-of-multiple-dispatch-your-favourite-examples/119477 "2025-01-10T09:38:16Z")

</div>

@Datseris asked if there’s a formally citable reference with the points, examples and concepts presented by @StefanKarpinski on The Unreasonable Effectiveness of Multiple Dispatch. In the slack discussion linked above, …

---

## [Looking for programmatic solutions](https://discourse.julialang.org/t/looking-for-programmatic-solutions/124525)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 7\
**Last updated:** [January 10, 2025, 9:01am UTC](https://discourse.julialang.org/t/looking-for-programmatic-solutions/124525 "2025-01-10T09:01:02Z")

</div>

I tried to solve, and in the end I succeeded (I had inserted a solution with extra white spaces so the answer was rejected even if substantially correct and this made me damn in the search for the error that was not in t…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=94)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=96)
