Dparam = parameters.shape[0] #dimension of the postulated model/parameter thetaweights = thetaweights / sum( thetaweights) #first transform to normalized ones xNormConst = sum(xweights, axis=0) grad = zeros(Ntheta) lap = zeros(Ntheta) hScore_theta = zeros(Ntheta) #store simple H score for each theta particle compositeHScore = zeros(1) simpleHScore = zeros(1) weave.inline(code,['states', 'y', 'parameters', 'thetaweights', 'xweights', 'xNormConst', 'hScore_theta', \ 'Nx', 'Ntheta', 'Dparam', 'grad', 'lap', 'compositeHScore', 'simpleHScore'], \ type_converters=weave.converters.blitz, libraries = ["m"]) return {"simpleHScore": simpleHScore, "compositeHScore": compositeHScore} modelx = SSM(name="Simplest model x", xdimension=1, ydimension=1, HScoreInference=HScoreInference, continuousObs=continuousObs) modelx.setComputeHscore(computeHscore) modelx.setFirstStateGenerator(firstStateGenerator) modelx.setObservationGenerator(observationGenerator) modelx.setTransitionAndWeight(transitionAndWeight) # Values used to generate the synthetic dataset when needed: # (untransformed parameters) modelx.setParameters(array([0.9])) modelx.addStateFiltering() modelx.addStatePrediction() modelx.addObsPrediction()