{"id":16499423,"url":"https://github.com/tpapp/scoread.jl","last_synced_at":"2026-01-27T20:14:57.673Z","repository":{"id":55588513,"uuid":"110720483","full_name":"tpapp/ScoreAD.jl","owner":"tpapp","description":"Score function method for gradient of simulated values using automatic differentiation","archived":false,"fork":false,"pushed_at":"2020-12-20T09:18:40.000Z","size":13,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T16:20:13.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-14T17:09:52.000Z","updated_at":"2019-06-14T01:41:53.000Z","dependencies_parsed_at":"2022-08-15T03:50:21.130Z","dependency_job_id":null,"html_url":"https://github.com/tpapp/ScoreAD.jl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpapp%2FScoreAD.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpapp%2FScoreAD.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpapp%2FScoreAD.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpapp%2FScoreAD.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpapp","download_url":"https://codeload.github.com/tpapp/ScoreAD.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241405077,"owners_count":19957764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T14:52:36.102Z","updated_at":"2026-01-27T20:14:57.638Z","avatar_url":"https://github.com/tpapp.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScoreAD\n\n[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](http://www.repostatus.org/badges/latest/wip.svg)](http://www.repostatus.org/#wip)\n[![Build Status](https://travis-ci.org/tpapp/ScoreAD.jl.svg?branch=master)](https://travis-ci.org/tpapp/ScoreAD.jl)\n[![Coverage Status](https://coveralls.io/repos/tpapp/ScoreAD.jl/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/tpapp/ScoreAD.jl?branch=master)\n[![codecov.io](http://codecov.io/github/tpapp/ScoreAD.jl/coverage.svg?branch=master)](http://codecov.io/github/tpapp/ScoreAD.jl?branch=master)\n\nScore function method for gradient of simulated values using automatic differentiation.\n\n## Introduction\n\nWhen `x ∼ F(⋅, β)`, integrals of the form\n\n```math\ns(β) = Eᵦ[h(x)] = ∫ h(x) dF(x,β)\n```\n\ncan be estimated by simulating values `xᵢ ∼ F(⋅, β)` from the distribution and taking the mean, ie\n\n```math\nŝ(β) = 1/N ∑ᵢ h(xᵢ)\n```\n\nWe are frequently interested in a Monte Carlo estimator for `∂s/∂β`. The “score function” trick is to multiply and divide by the density before differentiating, and use\n\n```math\n∂ŝ(β)/∂β = 1/N ∑ᵢ h(xᵢ) ∂log(f(x, β))/∂β\n```\n\nin Monte Carlo simulations. Note that various technical conditions are required for this (you need to be able to exchange the integral and the differentiation operators), see the references below.\n\nThis package implements `score_AD` and `score_AD_log` to program these seamlessly using automatic differentiation (currently [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) is supported). You can write, for example,\n\n```julia\ndist = SomeDistribution(β)\nmean(h(x) * score_AD(pdf(dist, β)) for x in xs)\n```\n\nor (note the log, which is preferred for numerical reasons)\n\n```julia\ndist = SomeDistribution(β)\nmean(h(x) * score_AD_log(logpdf(dist, β)) for x in xs)\n```\n\nand the resulting value calculation will “do the right thing”, and be seamlessly autodifferentiable.\n\nSee the unit tests for examples.\n\n## References\n\nThe literature for *score function* or *likelihood ratio* methods is vast. The following are a good starting points.\n\n- Fu, M. C. (2006). Gradient estimation. Handbooks in operations research and management science, 13, Chapter 19, 575–616.\n\n- Rubinstein, R. Y., \u0026 Kroese, D. P. (2016). Simulation and the Monte Carlo method, Chapter 7. John Wiley \\\u0026 Sons.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpapp%2Fscoread.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpapp%2Fscoread.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpapp%2Fscoread.jl/lists"}