Skip to content

Commit

Permalink
Update notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad committed Apr 27, 2020
1 parent 46bc0c7 commit 38ba0e3
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 48 deletions.
14 changes: 8 additions & 6 deletions examples/examples.ipynb
Expand Up @@ -703,25 +703,27 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"@webio": {
"lastCommId": null,
"lastKernelId": null
},
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Julia 0.7.0",
"display_name": "Julia 1.4.1",
"language": "julia",
"name": "julia-0.7"
"name": "julia-1.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.7.0"
"version": "1.4.1"
}
},
"nbformat": 4,
Expand Down
183 changes: 141 additions & 42 deletions examples/random_prefs.ipynb
Expand Up @@ -27,10 +27,10 @@
"data": {
"text/plain": [
"4×4 Array{Int64,2}:\n",
" 2 3 2 3\n",
" 3 2 0 1\n",
" 1 1 3 0\n",
" 0 0 1 2"
" 2 3 1 2\n",
" 0 2 0 1\n",
" 3 0 2 0\n",
" 1 1 3 3"
]
},
"execution_count": 3,
Expand All @@ -51,11 +51,11 @@
"data": {
"text/plain": [
"5×3 Array{Int64,2}:\n",
" 1 2 4\n",
" 4 0 1\n",
" 2 3 3\n",
" 3 1 2\n",
" 0 4 0"
" 2 3 1\n",
" 4 2 3\n",
" 3 4 4\n",
" 0 0 0\n",
" 1 1 2"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -85,9 +85,9 @@
"data": {
"text/plain": [
"4×4 Array{Int64,2}:\n",
" 3 2 1 2\n",
" 2 3 2 1\n",
" 1 1 3 3\n",
" 2 3 2 3\n",
" 1 2 1 2\n",
" 3 1 3 1\n",
" 0 0 0 0"
]
},
Expand All @@ -111,10 +111,10 @@
"data": {
"text/plain": [
"5×3 Array{Int64,2}:\n",
" 4 3 1\n",
" 3 2 2\n",
" 2 1 4\n",
" 1 4 3\n",
" 1 2 4\n",
" 3 3 3\n",
" 4 4 1\n",
" 2 1 2\n",
" 0 0 0"
]
},
Expand Down Expand Up @@ -145,10 +145,10 @@
"data": {
"text/plain": [
"4×4 Array{Int64,2}:\n",
" 1 3 3 1\n",
" 2 1 1 3\n",
" 0 0 0 2\n",
" 3 2 2 0"
" 3 2 3 3\n",
" 2 1 2 2\n",
" 1 0 1 1\n",
" 0 3 0 0"
]
},
"execution_count": 9,
Expand All @@ -169,11 +169,11 @@
"data": {
"text/plain": [
"5×3 Array{Int64,2}:\n",
" 1 3 4\n",
" 0 0 3\n",
" 3 1 1\n",
" 2 4 2\n",
" 4 2 0"
" 4 1 3\n",
" 1 3 0\n",
" 0 0 1\n",
" 2 4 4\n",
" 3 2 2"
]
},
"execution_count": 10,
Expand All @@ -194,9 +194,9 @@
"data": {
"text/plain": [
"3-element Array{Int64,1}:\n",
" 3\n",
" 2\n",
" 1\n",
" 3"
" 2"
]
},
"execution_count": 11,
Expand Down Expand Up @@ -226,9 +226,9 @@
"data": {
"text/plain": [
"4×4 Array{Int64,2}:\n",
" 3 1 2 1\n",
" 2 3 1 2\n",
" 1 2 3 3\n",
" 1 2 3 1\n",
" 2 1 1 3\n",
" 3 3 2 2\n",
" 0 0 0 0"
]
},
Expand All @@ -250,10 +250,10 @@
"data": {
"text/plain": [
"5×3 Array{Int64,2}:\n",
" 1 3 4\n",
" 2 2 2\n",
" 3 4 1\n",
" 4 1 3\n",
" 3 3 2\n",
" 1 4 1\n",
" 4 2 4\n",
" 2 1 3\n",
" 0 0 0"
]
},
Expand All @@ -276,8 +276,8 @@
"text/plain": [
"3-element Array{Int64,1}:\n",
" 2\n",
" 1\n",
" 1"
" 2\n",
" 2"
]
},
"execution_count": 15,
Expand All @@ -304,6 +304,103 @@
},
{
"data": {
"text/latex": [
"\\begin{verbatim}\n",
"random_prefs([rng, ]m, n[, ReturnCaps]; allow_unmatched=true)\n",
"\\end{verbatim}\n",
"Generate random preference order lists for two groups, say, m males and n females.\n",
"\n",
"Each male has a preference order over femals [1, ..., n] and \"unmatched\" which is represented by 0, while each female has a preference order over males [1, ..., m] and \"unmatched\" which is again represented by 0.\n",
"\n",
"The argument \\texttt{ReturnCaps} should be supplied in the context of college admissions, in which case \"males\" and \"females\" should be read as \"students\" and \"colleges\", respectively, where each college has its capacity.\n",
"\n",
"The optional \\texttt{rng} argument specifies a random number generator.\n",
"\n",
"\\section{Arguments}\n",
"\\begin{itemize}\n",
"\\item \\texttt{m::Integer} : Number of males.\n",
"\n",
"\n",
"\\item \\texttt{n::Integer} : Number of females.\n",
"\n",
"\n",
"\\item \\texttt{::Type\\{ReturnCaps\\}} : If supplied, \\texttt{caps} is also returned.\n",
"\n",
"\n",
"\\item \\texttt{;allow\\_unmatched::Bool(true)} : If false, return preference order lists of males and females where 0 is always placed in the last place, (i.e., \"unmatched\" is least preferred by every individual).\n",
"\n",
"\\end{itemize}\n",
"\\section{Returns}\n",
"\\begin{itemize}\n",
"\\item \\texttt{m\\_prefs::Matrix\\{Int\\}} : Array of shape (n+1, m), where each column contains a random permutation of 0, 1, ..., n.\n",
"\n",
"\n",
"\\item \\texttt{f\\_prefs::Matrix\\{Int\\}} : Array of shape (m+1, n), where each column contains a random permutation of 0, 1, ..., m.\n",
"\n",
"\n",
"\\item \\texttt{caps::Vector\\{Int\\}} : Vector of length n containing each female's (or college's) capacity. Returned only when \\texttt{ReturnCaps} is supplied.\n",
"\n",
"\\end{itemize}\n",
"\\section{Examples}\n",
"\\begin{verbatim}\n",
"julia> m_prefs, f_prefs = random_prefs(4, 3);\n",
"\n",
"julia> m_prefs\n",
"4x4 Array{Int64,2}:\n",
" 3 3 1 3\n",
" 0 2 3 1\n",
" 2 1 2 0\n",
" 1 0 0 2\n",
"\n",
"julia> f_prefs\n",
"5x3 Array{Int64,2}:\n",
" 1 2 4\n",
" 4 3 1\n",
" 3 4 2\n",
" 0 0 0\n",
" 2 1 3\n",
"\n",
"julia> m_prefs, f_prefs = random_prefs(4, 3, allow_unmatched=false);\n",
"\n",
"julia> m_prefs\n",
"4x4 Array{Int64,2}:\n",
" 1 3 1 2\n",
" 2 1 3 3\n",
" 3 2 2 1\n",
" 0 0 0 0\n",
"\n",
"julia> f_prefs\n",
"5x3 Array{Int64,2}:\n",
" 1 2 3\n",
" 2 3 4\n",
" 4 1 1\n",
" 3 4 2\n",
" 0 0 0\n",
"\n",
"julia> s_prefs, c_prefs, caps = random_prefs(4, 3, ReturnCaps);\n",
"\n",
"julia> s_prefs\n",
"4x4 Array{Int64,2}:\n",
" 2 1 2 1\n",
" 1 3 1 0\n",
" 3 2 3 3\n",
" 0 0 0 2\n",
"\n",
"julia> c_prefs\n",
"5x3 Array{Int64,2}:\n",
" 3 4 1\n",
" 0 1 4\n",
" 4 3 0\n",
" 1 2 3\n",
" 2 0 2\n",
"\n",
"julia> caps\n",
"3-element Array{Int64,1}:\n",
" 1\n",
" 2\n",
" 2\n",
"\\end{verbatim}\n"
],
"text/markdown": [
"```\n",
"random_prefs([rng, ]m, n[, ReturnCaps]; allow_unmatched=true)\n",
Expand Down Expand Up @@ -506,24 +603,26 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"@webio": {
"lastCommId": null,
"lastKernelId": null
},
"kernelspec": {
"display_name": "Julia 0.7.0",
"display_name": "Julia 1.4.1",
"language": "julia",
"name": "julia-0.7"
"name": "julia-1.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.7.0"
"version": "1.4.1"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 38ba0e3

Please sign in to comment.