import pymc as pm
import numpy as np

def model(data):
    age = data['age']
    length = data['length']
    
    with pm.Model() as dugong_model:
        # Priors for the von Bertalanffy-like growth model: L = L_max * (1 - exp(-k * age))
        # L_max: Asymptotic maximum length
        # k: Growth rate coefficient
        
        # Based on summary stats:
        # Max length is ~2.74, so L_max should be slightly higher.
        # We use a HalfNormal with a sigma large enough to cover plausible values.
        L_max = pm.HalfNormal('L_max', sigma=2.0)
        
        # k should be positive. A HalfNormal with sigma=1 is a reasonable weakly informative prior.
        k = pm.HalfNormal('k', sigma=1.0)
        
        # Deterministic growth curve
        mu = L_max * (1 - pm.math.exp(-k * age))
        
        # Likelihood
        # sigma is the standard deviation of the observation error
        sigma = pm.HalfNormal('sigma', sigma=0.5)
        
        likelihood = pm.Normal('likelihood', mu=mu, sigma=sigma, observed=length)
        
    return dugong_model
