Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed Jul 7, 2024
1 parent 06bd30b commit 4ff8516
Show file tree
Hide file tree
Showing 36 changed files with 191,090 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cognitive Models with Julia
# Cognitive Models with Julia <img src='content/median/cover.png' align="right" height="200" />

[![](https://img.shields.io/badge/status-looking_for_collaborators-orange)](https://github.com/DominiqueMakowski/CognitiveModels/issues)
[![](https://img.shields.io/badge/access-open-green)](https://dominiquemakowski.github.io/CognitiveModels/)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "cef1b013",
"metadata": {},
"outputs": [],
"source": [
"import IJulia\n",
"\n",
"# The julia kernel has built in support for Revise.jl, so this is the \n",
"# recommended approach for long-running sessions:\n",
"# https://github.com/JuliaLang/IJulia.jl/blob/9b10fa9b879574bbf720f5285029e07758e50a5e/src/kernel.jl#L46-L51\n",
"\n",
"# Users should enable revise within .julia/config/startup_ijulia.jl:\n",
"# https://timholy.github.io/Revise.jl/stable/config/#Using-Revise-automatically-within-Jupyter/IJulia-1\n",
"\n",
"# clear console history\n",
"IJulia.clear_history()\n",
"\n",
"fig_width = 7\n",
"fig_height = 5\n",
"fig_format = :retina\n",
"fig_dpi = 96\n",
"\n",
"# no retina format type, use svg for high quality type/marks\n",
"if fig_format == :retina\n",
" fig_format = :svg\n",
"elseif fig_format == :pdf\n",
" fig_dpi = 96\n",
" # Enable PDF support for IJulia\n",
" IJulia.register_mime(MIME(\"application/pdf\"))\n",
"end\n",
"\n",
"# convert inches to pixels\n",
"fig_width = fig_width * fig_dpi\n",
"fig_height = fig_height * fig_dpi\n",
"\n",
"# Intialize Plots w/ default fig width/height\n",
"try\n",
" import Plots\n",
"\n",
" # Plots.jl doesn't support PDF output for versions < 1.28.1\n",
" # so use png (if the DPI remains the default of 300 then set to 96)\n",
" if (Plots._current_plots_version < v\"1.28.1\") & (fig_format == :pdf)\n",
" Plots.gr(size=(fig_width, fig_height), fmt = :png, dpi = fig_dpi)\n",
" else\n",
" Plots.gr(size=(fig_width, fig_height), fmt = fig_format, dpi = fig_dpi)\n",
" end\n",
"catch e\n",
" # @warn \"Plots init\" exception=(e, catch_backtrace())\n",
"end\n",
"\n",
"# Initialize CairoMakie with default fig width/height\n",
"try\n",
" import CairoMakie\n",
"\n",
" # CairoMakie's display() in PDF format opens an interactive window\n",
" # instead of saving to the ipynb file, so we don't do that.\n",
" # https://github.com/quarto-dev/quarto-cli/issues/7548\n",
" if fig_format == :pdf\n",
" CairoMakie.activate!(type = \"png\")\n",
" else\n",
" CairoMakie.activate!(type = string(fig_format))\n",
" end\n",
" CairoMakie.update_theme!(resolution=(fig_width, fig_height))\n",
"catch e\n",
" # @warn \"CairoMakie init\" exception=(e, catch_backtrace())\n",
"end\n",
" \n",
"# Set run_path if specified\n",
"try\n",
" run_path = raw\"C:\\Users\\domma\\Dropbox\\Software\\CognitiveModels\\content\"\n",
" if !isempty(run_path)\n",
" cd(run_path)\n",
" end\n",
"catch e\n",
" @warn \"Run path init:\" exception=(e, catch_backtrace())\n",
"end\n",
"\n",
"\n",
"# emulate old Pkg.installed beahvior, see\n",
"# https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416/9\n",
"import Pkg\n",
"function isinstalled(pkg::String)\n",
" any(x -> x.name == pkg && x.is_direct_dep, values(Pkg.dependencies()))\n",
"end\n",
"\n",
"# ojs_define\n",
"if isinstalled(\"JSON\") && isinstalled(\"DataFrames\")\n",
" import JSON, DataFrames\n",
" global function ojs_define(; kwargs...)\n",
" convert(x) = x\n",
" convert(x::DataFrames.AbstractDataFrame) = Tables.rows(x)\n",
" content = Dict(\"contents\" => [Dict(\"name\" => k, \"value\" => convert(v)) for (k, v) in kwargs])\n",
" tag = \"<script type='ojs-define'>$(JSON.json(content))</script>\"\n",
" IJulia.display(MIME(\"text/html\"), tag)\n",
" end\n",
"elseif isinstalled(\"JSON\")\n",
" import JSON\n",
" global function ojs_define(; kwargs...)\n",
" content = Dict(\"contents\" => [Dict(\"name\" => k, \"value\" => v) for (k, v) in kwargs])\n",
" tag = \"<script type='ojs-define'>$(JSON.json(content))</script>\"\n",
" IJulia.display(MIME(\"text/html\"), tag)\n",
" end\n",
"else\n",
" global function ojs_define(; kwargs...)\n",
" @warn \"JSON package not available. Please install the JSON.jl package to use ojs_define.\"\n",
" end\n",
"end\n",
"\n",
"\n",
"# don't return kernel dependencies (b/c Revise should take care of dependencies)\n",
"nothing\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "53bd139d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.01"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Distributions\n",
"\n",
"# Reparameterized Beta distribution\n",
"function BetaMod(μ, σ)\n",
" α = μ * (μ * (1 - μ) / σ^2 - 1)\n",
" β = α * (1 - μ) / μ\n",
" return Beta(α, β)\n",
"end\n",
"\n",
"\n",
"\n",
"mean(BetaMod(0.5, 0.0833))\n",
"var(BetaMod(0.2, 0.1))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file modified content/.jupyter_cache/global.db
Binary file not shown.
12 changes: 12 additions & 0 deletions content/.quarto/_freeze/3_scales/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"hash": "b7153c2b346aaba747f06dca75c74302",
"result": {
"engine": "jupyter",
"markdown": "# Choice and Scales\n\n![](https://img.shields.io/badge/status-not_started-red)\n\n1. Beta models \n\n::: {#53bd139d .cell execution_count=1}\n``` {.julia .cell-code}\nusing Distributions\n\n# Reparameterized Beta distribution\nfunction BetaMod(μ, σ)\n α = μ * (μ * (1 - μ) / σ^2 - 1)\n β = α * (1 - μ) / μ\n return Beta(α, β)\nend\n\n\n\nmean(BetaMod(0.5, 0.0833))\nvar(BetaMod(0.2, 0.1))\n```\n\n::: {.cell-output .cell-output-display execution_count=2}\n```\n0.01\n```\n:::\n:::\n\n\n2. OrdBeta models for slider scales\n3. Logistic models for binary data\n\nUse the speed accuracy data that we use in the next chapter.\n\n",
"supporting": [
"3_scales_files"
],
"filters": [],
"includes": {}
}
}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/.quarto/cites/index.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"4_rt.qmd":["wagenmakers2008diffusion","heathcote2012linear","theriault2024check","lo2015transform","schramm2019reaction","balota2011moving","matzke2009psychological","hohle1965inferred","kieffaber2006switch","matzke2009psychological","schwarz2001ex","heathcote2004fitting","anders2016shifted"],"2_predictors.qmd":[],"4_1_Normal.qmd":["wagenmakers2008diffusion","theriault2024check","lo2015transform","schramm2019reaction"],"1_introduction.qmd":[],"3_scales.qmd":[],"index.qmd":[],"references.qmd":[],"4a_rt_descriptive.qmd":["wagenmakers2008diffusion","heathcote2012linear","theriault2024check","lo2015transform","schramm2019reaction","balota2011moving","matzke2009psychological","hohle1965inferred","kieffaber2006switch","matzke2009psychological","schwarz2001ex","heathcote2004fitting","anders2016shifted"],"5_individual.qmd":[],"4b_rt_generative.qmd":[]}
{"4a_rt_descriptive.qmd":["wagenmakers2008diffusion","heathcote2012linear","theriault2024check","lo2015transform","schramm2019reaction","wagenmakers2005relation","limpert2001log","balota2011moving","matzke2009psychological","hohle1965inferred","kieffaber2006switch","matzke2009psychological","schwarz2001ex","heathcote2004fitting","anders2016shifted"],"5_individual.qmd":[],"2_predictors.qmd":[],"3_scales.qmd":[],"references.qmd":[],"1_introduction.qmd":[],"index.qmd":[],"4b_rt_generative.qmd":[],"4_rt.qmd":["wagenmakers2008diffusion","heathcote2012linear","theriault2024check","lo2015transform","schramm2019reaction","balota2011moving","matzke2009psychological","hohle1965inferred","kieffaber2006switch","matzke2009psychological","schwarz2001ex","heathcote2004fitting","anders2016shifted"],"4_1_Normal.qmd":["wagenmakers2008diffusion","theriault2024check","lo2015transform","schramm2019reaction"]}
Loading

0 comments on commit 4ff8516

Please sign in to comment.