Skip to content

Instantly share code, notes, and snippets.

@antimon2
Created August 19, 2020 16:03
Show Gist options
  • Save antimon2/dbeeaa0a34a19dd7aeb96314fe717c03 to your computer and use it in GitHub Desktop.
Save antimon2/dbeeaa0a34a19dd7aeb96314fe717c03 to your computer and use it in GitHub Desktop.
TupleDistribution.jl.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T15:58:53.814Z",
"end_time": "2020-08-20T00:58:55.426000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "versioninfo()",
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": "Julia Version 1.5.0\nCommit 96786e22cc (2020-08-01 23:44 UTC)\nPlatform Info:\n OS: Linux (x86_64-pc-linux-gnu)\n CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\n WORD_SIZE: 64\n LIBM: libopenlibm\n LLVM: libLLVM-9.0.1 (ORCJIT, skylake)\n",
"name": "stdout"
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T15:59:16.266Z",
"end_time": "2020-08-20T00:59:16.754000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "f(x) = (x+2, x*2, x^2)",
"execution_count": 2,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 2,
"data": {
"text/plain": "f (generic function with 1 method)"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T15:59:29.351Z",
"end_time": "2020-08-20T00:59:29.653000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "a, b, c = f(1)",
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 3,
"data": {
"text/plain": "(3, 2, 1)"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T15:59:43.386Z",
"end_time": "2020-08-20T00:59:44.163000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "X = [1, 2, 3]",
"execution_count": 4,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 4,
"data": {
"text/plain": "3-element Array{Int64,1}:\n 1\n 2\n 3"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T15:59:47.114Z",
"end_time": "2020-08-20T00:59:47.957000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "f.(X)",
"execution_count": 5,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 5,
"data": {
"text/plain": "3-element Array{Tuple{Int64,Int64,Int64},1}:\n (3, 2, 1)\n (4, 4, 4)\n (5, 6, 9)"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T16:00:02.155Z",
"end_time": "2020-08-20T01:00:02.485000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "A, B, C = zip(f.(X)...)",
"execution_count": 6,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 6,
"data": {
"text/plain": "zip((3, 2, 1), (4, 4, 4), (5, 6, 9))"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T16:00:05.234Z",
"end_time": "2020-08-20T01:00:05.250000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "A",
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 7,
"data": {
"text/plain": "(3, 4, 5)"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T16:00:06.672Z",
"end_time": "2020-08-20T01:00:06.689000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "B",
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 8,
"data": {
"text/plain": "(2, 4, 6)"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2020-08-19T16:00:07.468Z",
"end_time": "2020-08-20T01:00:07.485000+09:00"
},
"trusted": true
},
"cell_type": "code",
"source": "C",
"execution_count": 9,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 9,
"data": {
"text/plain": "(1, 4, 9)"
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "julia-1.5",
"display_name": "Julia 1.5.0",
"language": "julia"
},
"language_info": {
"file_extension": ".jl",
"name": "julia",
"mimetype": "application/julia",
"version": "1.5.0"
},
"gist": {
"id": "",
"data": {
"description": "TupleDistribution.jl.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment