Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlim of traceplot does not cover all range of values #585

Closed
aakhmetz opened this issue Feb 9, 2019 · 4 comments · Fixed by #586
Closed

xlim of traceplot does not cover all range of values #585

aakhmetz opened this issue Feb 9, 2019 · 4 comments · Fixed by #586

Comments

@aakhmetz
Copy link

aakhmetz commented Feb 9, 2019

Description of your problem

xlim of traceplot may not cover all range of traces for discrete variables. For example, if I get two chains: one with mean 28, another one with mean 32. Then the traceplot will show only one bar at x=28 and xlim from 27.5 to 28.5.

arcolinux_2019-01-27_16-01-25

For discrete values I used DiscreteUniform:

timestep=1.5
with pm.Model() as model_two_switches_11:
    delaymean = pm.Uniform('delaymean',1,28,shape=3)
    k = pm.Uniform('k',0.8,8,shape=3)
    
    switch1 = pm.DiscreteUniform('switch1',df['T'].min()//7,df['T'].max()//7-timestep-1)
    switch2 = pm.DiscreteUniform('switch2',switch1+timestep+1,df['T'].max()//7)
    
    idx = tt.switch(df['t'].values>=(switch1*7),0,1)+tt.switch(df['t'].values>=(switch2*7),0,1)
    
    θ = delaymean/tt.gamma(1+1/k)
    delaysd = pm.Deterministic('delaysd',delaymean/tt.gamma(1+1/k)*tt.sqrt(tt.gamma(1+2/k)-tt.gamma(1+1/k)**2))
    
    delay_p = (1-tt.exp(-(df['δt0'].values/θ[idx])**k[idx]))/(1-tt.exp(-(df['δt'].values/θ[idx])**k[idx]))
    
    confirmed = pm.Poisson('confirmed',\
                    mu=df['confirmed'].values*delay_p+0.001,\
                    observed=df['confirmed0'].values)
    
    start = {'switch1': 22, 'switch2': 28}
    step = pm.Slice([switch1,switch2])
    trace_two_switches_11 = pm.sample(number_of_iterations, tune=length_of_tunein, cores = number_of_jobs,
                                      start=start, step=step)

model_two_switches_11.name = 'Two switches_11'

vrnames = ['switch1','switch2','delaymean','delaysd']
pm.traceplot(trace_two_switches_11,varnames=vrnames);
pm.summary(trace_two_switches_11)

ps: I assume that it's because the fraction of those points outside of chosen xlim-range is rather small, but it would be nice to see the consistent picture between left and right panels

Versions and main components

  • PyMC3 Version: 3.6
  • Theano Version: 1.0.3
  • Python Version: 3.7.1
  • Operating system: linux
  • How did you install PyMC3: (conda/pip) latest version from github
@ahartikainen
Copy link
Contributor

This is with pip arviz?

I think we could force minimum xlim length to 3 with discrete parameters.

@aakhmetz
Copy link
Author

aakhmetz commented Feb 9, 2019

Thank you for your reply. Probably I needed to give more details - my issue was orinally posted on pymc3, but I was then directed here, see pymc-devs/pymc#3359.

I used the default provided by pymc3, and I didn't call out arviz specifically in my program.

@aloctavodia
Copy link
Contributor

@aakhmetz thanks for reporting this problem. I think I know were is the problem, I will check and send a PR soon. @ahartikainen I think this is due to how we set the xticks for histograms

@ahartikainen
Copy link
Contributor

Ok, sound good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants