Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Traversing a binomial tree help
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Traversing a binomial tree help
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01097850
Message ID:
01097850
Vues:
68
Hi All,

I have a binomial tree structure. I want to get all the possible paths in this tree, I have been searching for an elegant way to do this. I'll explain with an example:

A person starts with disability state 0, the following year he can get disabled and reaches state 1 or he stays active in the same state 0 (so there are two states in year 1 (2^time)). The following year 2 he can get disabled for the first time 0->1, or he stays active 0->0, or he gets better 1->0, or he disables more 1->2 (so 2^2 possibilities). And so on....

I want to make a function that returns a array of strings of all possible paths given a specific duration, so :
for year 0 : "0"
for year 1:  "01"
          :  "00"
for year 2:  "000"
             "001"
             "012"
             "010"
for year n: 2^n possibilities
I have been trying to make a readable code for this, but with no success. Any ideas?

Thanks beforehand.
Zakaria al Azhar
My blog on Actuaris.net
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform