From 9aba5a66b399dac7fc5f2192d090f5b72469cb51 Mon Sep 17 00:00:00 2001 From: Daisuke Oyama Date: Mon, 27 Apr 2020 15:55:53 +0900 Subject: [PATCH] Update notebooks --- examples/examples.ipynb | 14 +-- examples/random_prefs.ipynb | 183 +++++++++++++++++++++++++++--------- 2 files changed, 149 insertions(+), 48 deletions(-) diff --git a/examples/examples.ipynb b/examples/examples.ipynb index 0edb8fb..8daf40c 100644 --- a/examples/examples.ipynb +++ b/examples/examples.ipynb @@ -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, diff --git a/examples/random_prefs.ipynb b/examples/random_prefs.ipynb index d58af80..7c90fee 100644 --- a/examples/random_prefs.ipynb +++ b/examples/random_prefs.ipynb @@ -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, @@ -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, @@ -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" ] }, @@ -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" ] }, @@ -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, @@ -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, @@ -194,9 +194,9 @@ "data": { "text/plain": [ "3-element Array{Int64,1}:\n", + " 3\n", " 2\n", - " 1\n", - " 3" + " 2" ] }, "execution_count": 11, @@ -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" ] }, @@ -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" ] }, @@ -276,8 +276,8 @@ "text/plain": [ "3-element Array{Int64,1}:\n", " 2\n", - " 1\n", - " 1" + " 2\n", + " 2" ] }, "execution_count": 15, @@ -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", @@ -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,