Re: buliding on functions
- To: mathgroup at smc.vnet.net
- Subject: [mg79176] Re: buliding on functions
- From: "JGBoone at gmail.com" <JGBoone at gmail.com>
- Date: Fri, 20 Jul 2007 03:28:22 -0400 (EDT)
- References: <f7f2pb$o7k$1@smc.vnet.net><f7hs43$s7c$1@smc.vnet.net>
this is the set of functions i want to work.
ogspecies = 10;
(*set up sizes for communitysize and metacommunity*)
Q = R = S = Range[ogspecies];
(*makes a vector called communityA with sequencal elements 1 to
ogspecies*)
combine = {Q, R, S};
(*puts communitys into three groupings not broken down*)
metacommunity = FlattenAt[combine, {{1}, {2}, {3}}];
(*puts all communities into one large metacommunity*)
speciation = 1 + Last[Sort[metacommunity]];
unlikeliness = 6;(*sets up chance of speciation.bigger number means
less \
likely*)
metalikeliness = 30;(*sets up chance of immigration.bigger number
means
less likely*)
generations = 10;
(*time steps that the funtion runs which is given as size squared;
this \
excepted time to monodomince*)
hubl[group_] := group[[Random[Integer, {1, orspecies}]]];
(*takes a random element of group*)
SpeciesCount[group_] := Length[Split[Sort[group]]];
metareplace[group_] := Module[{grp = group}, (grp[[Random[Integer, {1,
\
ogspecies}]]] = hubl[metacommunity])];
(*takes random element of community size and replaces it with random
element \
of metacommunity by way of the function hubl[group_]*)
communityreplace[group_] := Module[{grp = group},
(grp[[Random[Integer, {1, \
ogspecies}]]] = hubl[grp])];
(*takes a random
element of communitysize and replaces it with
another random element of community size by
way of the function hubl[group_]*)
metachance[group_] := Random[Integer, {1, metalikeliness}] == 1;
(*creates a \
function that tests if a random integer from 1 to metalikeliness is
equal to \
1. this makes the chance of speciation equal to 1/metalikeliness*)
immigration[group_] := If[metachance[group], metareplace[group], \
communityreplace[group]];
chance := Random[Integer, {1, unlikeliness}] == 1;
(*creates a function that tests if a random integer from 1 to
unlikeliness
is equal to 1. this makes the chance of speciation equal to \
1/unlikeliness*)
changing[group_] : = If[chance, speciation[group],
immigration[group]];
randomwalks[group_] := Table[changing[group]; {t,
SpeciesCount[group]}, {t, \
1, generations}];
(*creates a table of the function SpeciesCount from time step 1 till
time
step 100*)
Print[randomwalks[Q,R,S]]
But it is not running the functions on Q,R, and S congruently. I know
theres other issues with this as well.