In [2]:
include("preparation.jl");
include("bayes.jl");
include("simulation.jl");


WARNING: Method definition betainvcdf(Number, Number, Array) in module Main at /Users/susu/Desktop/Hong Kong/RA/voting_git/preparation.jl:7 overwritten at /Users/susu/Desktop/Hong Kong/RA/voting_git/simulation.jl:10.
WARNING: Method definition max(Real, Any) in module Main at /Users/susu/Desktop/Hong Kong/RA/voting_git/preparation.jl:12 overwritten at /Users/susu/Desktop/Hong Kong/RA/voting_git/simulation.jl:12.
WARNING: Method definition normpdf(Array{Float64, 2}) in module Main at /Users/susu/Desktop/Hong Kong/RA/voting_git/preparation.jl:16 overwritten at /Users/susu/Desktop/Hong Kong/RA/voting_git/simulation.jl:14.

最初の設定の結果


In [21]:
param = squeeze(array(readtable("20170130.txt", header = false))', 2)


Out[21]:
275-element Array{Float64,1}:
  9.82213e8 
 -1.0       
 -3.13043e16
 -2.05441e16
 -2.0164e16 
 -3.68378e15
  8.52519e15
  2.02576e16
  2.0463e16 
  1.61859e16
  5.21091e16
  4.22355e15
 -8.59748e15
  ⋮         
  3.53691e16
  2.70391e16
 -1.1536e16 
 -1.17649e16
 -1.87702e16
 -3.96839e16
 -4.43395e16
  3.03369e15
  4.68159e16
 -2.60458e16
 -3.38086e16
  2.13143e16

In [24]:
m = simulation(param)
v = simulate(m)


Out[24]:
3020×4 Array{Float64,2}:
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 0.0       0.0       0.0       1.0     
 ⋮                                     
 0.286138  0.123338  0.286138  0.286138
 0.287796  0.124053  0.287796  0.287796
 0.286806  0.123626  0.286806  0.286806
 0.287959  0.124123  0.287959  0.287959
 0.287081  0.123745  0.287081  0.287081
 0.284743  0.122737  0.284743  0.284743
 0.286456  0.123475  0.286456  0.286456
 0.286497  0.123493  0.286497  0.286497
 0.285682  0.123142  0.285682  0.285682
 0.287723  0.124021  0.287723  0.287723
 0.289213  0.124664  0.289213  0.289213
 0.285904  0.123237  0.285904  0.285904

In [25]:
candcand(m, 0, v)


WARNING: the no-op `transpose` fallback is deprecated, and no more specific `transpose` method for Ptr{PyCall.PyObject_struct} exists. Consider `permutedims(x, [2, 1])` or writing a specific `transpose(x::Ptr{PyCall.PyObject_struct})` method if appropriate.
 in depwarn(::String, ::Symbol) at ./deprecated.jl:64
 in transpose(::Ptr{PyCall.PyObject_struct}) at ./deprecated.jl:770
 in transpose_f!(::Base.#transpose, ::Array{Ptr{PyCall.PyObject_struct},2}, ::Array{Ptr{PyCall.PyObject_struct},2}) at ./arraymath.jl:369
 in transpose(::Array{Ptr{PyCall.PyObject_struct},2}) at ./arraymath.jl:407
 in copy(::PyCall.PyArray{Ptr{PyCall.PyObject_struct},2}) at /Users/susu/.julia/v0.5/PyCall/src/numpy.jl:337
 in convert(::Type{Array{Ptr{PyCall.PyObject_struct},N}}, ::PyCall.PyObject) at /Users/susu/.julia/v0.5/PyCall/src/numpy.jl:453
 in convert(::Type{Array{PyCall.PyObject,N}}, ::PyCall.PyObject) at /Users/susu/.julia/v0.5/PyCall/src/numpy.jl:484
 in (::PyCall.##8#9{DataType,PyCall.PyObject})(::Int64) at /Users/susu/.julia/v0.5/PyCall/src/conversions.jl:180
 in ntuple(::PyCall.##8#9{DataType,PyCall.PyObject}, ::Int64) at ./tuple.jl:65
 in convert(::Type{Tuple{PyPlot.Figure,Array{PyCall.PyObject,N}}}, ::PyCall.PyObject) at /Users/susu/.julia/v0.5/PyCall/src/conversions.jl:180
 in convert(::Type{PyCall.PyAny}, ::PyCall.PyObject) at /Users/susu/.julia/v0.5/PyCall/src/conversions.jl:806
 in #pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::Int64, ::Vararg{Int64,N}) at /Users/susu/.julia/v0.5/PyCall/src/PyCall.jl:568
 in (::PyCall.#kw##pycall)(::Array{Any,1}, ::PyCall.#pycall, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::Int64, ::Vararg{Int64,N}) at ./<missing>:0
 in #subplots#115(::Array{Any,1}, ::Function, ::Int64, ::Vararg{Int64,N}) at /Users/susu/.julia/v0.5/PyPlot/src/PyPlot.jl:399
 in (::PyPlot.#kw##subplots)(::Array{Any,1}, ::PyPlot.#subplots, ::Int64, ::Vararg{Int64,N}) at ./<missing>:0
 in candcand(::simulation, ::Int64, ::Array{Float64,2}) at /Users/susu/Desktop/Hong Kong/RA/voting_git/simulation.jl:337
 in include_string(::String, ::String) at ./loading.jl:441
 in execute_request(::ZMQ.Socket, ::IJulia.Msg) at /Users/susu/.julia/v0.5/IJulia/src/execute_request.jl:169
 in eventloop(::ZMQ.Socket) at /Users/susu/.julia/v0.5/IJulia/src/eventloop.jl:8
 in (::IJulia.##9#15)() at ./task.jl:360
while loading In[25], in expression starting on line 1

In [26]:
state_vote(m, v)



In [ ]:
rate_histo(m, v)

In [ ]:
demo(m,"race", 0, v)

In [ ]:
demo(m,"edu", 0, v)

In [ ]:
demo(m,"income", 0, v)