## Repeat blockscount and contains the statements which are to be repeated:
For an integer count, a repeat block is equivalent to a ForEach block, in the sense that it repeats the contained statements ## Using repeat blocks to speed up inferenceWhen parts of a model are repeated identically, repeat blocks can lead to substantial speed-ups. For example, suppose we wish to learn the probability of heads of a coin from 10,000,000 tosses. Let's say we are given a bool arrayflips containing these coin tosses. The standard approach in Infer.NET would be:
Intuitively this seems very inefficient - we have to allocate and process large arrays. The code will take longer and longer as we make more and more coin tosses. In this particular model, all tosses which give heads are equivalent, as are all tosses that give tails. So we can just record the counts of heads and tails instead of all individual coin tosses. Repeat blocks provide a consistent way to do this for any type of model. Here is how we can write the same model using repeat blocks, assuming we now have counts of heads and tails in the variables
Inference of ## Other uses of repeat blocksThis section describes an experimental use of repeat blocks The count argument of a repeat block can be any real number, including fractions and negative numbers. This has no correspondence to traditional programming, but it does make sense in terms of factor graphs. Essentially the repeat block is raising the contained factors to a power. If the power is a positive integer |