2014-09-24 3 views
0

PyMC를 배우기 시작하고 첫 번째 튜토리얼의 예를 이해하기 위해 실마리를 시작합니다. early_mean 및 late_mean는 속도 지수 분포 다음 확률 변수로서 모델화 이유 PyMC의 재난 모델 이해

disasters_array = \ 
 
    np.array([ 4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, 
 
        3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5, 
 
        2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0, 
 
        1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1, 
 
        0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2, 
 
        3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4, 
 
        0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1]) 
 
switchpoint = DiscreteUniform('switchpoint', lower=0, upper=110, doc='Switchpoint[year]') 
 
early_mean = Exponential('early_mean', beta=1.) 
 
late_mean = Exponential('late_mean', beta=1.)

이 이해하지는 = 1 내 직감은 결정적 계산 disasters_array 사용하고 가변 예를 스윗치한다는 것이다

답변

0

disasters_array

@deterministic(plot=False) 
 
def early_mean(s=switchpoint): 
 
    return sum(disasters_array[:(s-1)])/(s-1) 
 

 
@deterministic(plot=False) 
 
def late_mean(s=switchpoint): 
 
    return sum(disasters_array[s:])/s

이 모델의 전제하에 포아송 프로세스에 의해 생성 된 데이터이다. late_meanearly_mean은 시계열이 언제 발생했는지에 따라이 프로세스와 관련된 매개 변수입니다. 매개 변수의 실제 값은 알 수 없으므로 확률 변수로 지정됩니다. 결정 성있는 객체는 부모의 값에 의해 결정되는 완전 인 노드에만 해당됩니다.

0

early_meanlate_mean stochastics을 모델 매개 변수로, Exponential을이 매개 변수의 사전 분포로 생각하십시오. 여기 모델의 버전에서 결정적 r 및 가능성 D은 MCMC 샘플링을 통해 early_meanlate_mean에 대한 후행으로 이어집니다.