Gen

1 program Added 2026-03-12T10:00:00Z Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled Evidence Report issue View issues
Aliases: Gen.jl
Provenance: commit ee7807b5c9 · authored 2026-03-12T01:12:42+01:00 · agent claude-code · model claude-sonnet-4-6

Sources mentioning this language

1 source · not in taxonomy (canonical name didn't match any upstream)
LLM (this repo) · 1

Related languages

Genshi (0.20)Gentee (0.20)GENTLE (0.20)GeneXus (0.19)Genyris (0.19)

LLM-contributed programs

Bayesian Linear Regression

Provenance: commit ee7807b5c9 · authored 2026-03-12T01:12:42+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
code.jl · license: Apache-2.0 · added: 2026-03-12T10:00:00Z
using Gen

# Define a simple Bayesian linear regression model
@gen function linear_regression(xs::Vector{Float64})
    slope = @trace(normal(0.0, 2.0), :slope)
    intercept = @trace(normal(0.0, 2.0), :intercept)
    noise = @trace(gamma(2.0, 0.5), :noise)
    for (i, x) in enumerate(xs)
        @trace(normal(slope * x + intercept, noise), (:y, i))
    end
end

# Sample some observed data
xs = [1.0, 2.0, 3.0, 4.0, 5.0]
ys = [2.1, 3.9, 6.2, 8.1, 10.0]

# Condition on observations
observations = choicemap()
for (i, y) in enumerate(ys)
    observations[(:y, i)] = y
end

# Run importance sampling to infer slope and intercept
traces, log_weights, _ = importance_sampling(linear_regression, (xs,), observations, 1000)

# Estimate posterior means
slopes = [tr[:slope] for tr in traces]
intercepts = [tr[:intercept] for tr in traces]
weights = exp.(log_weights .- logsumexp(log_weights))

println("Posterior mean slope:     ", sum(slopes .* weights))
println("Posterior mean intercept: ", sum(intercepts .* weights))

Contribute — propose a file extension

Tell us where to find evidence about Gen (mapped to pl/gen). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Gen/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← gemtext Gen Alpha →