[Date Index]
[Thread Index]
[Author Index]
A program check
*To*: mathgroup at smc.vnet.net
*Subject*: [mg75505] A program check
*From*: "JGBoone at gmail.com" <JGBoone at gmail.com>
*Date*: Thu, 3 May 2007 03:48:47 -0400 (EDT)
i was wondering if someone could check this program and see if its
running like the Description typed under each line says its suppose
to.
ogspecies=10000;(*set up sizes for communitysize and metacommunity*)
communitysize= Range[ogspecies];(*makes a vector called communitysize
with sequencal elements 1 to ogspecies*)
metacommunity=Range[ogspecies];(*makes a vector called communitysize
with sequencal elements 1 to ogspecies*)
unlikeliness= 6000;(*sets up chance of speciation.bigger number means
less likely*)
metalikeliness=30;
(*sets up chance of immigration. bigger number means less likely*)
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*)
metachance:=Random[Integer,{1,metalikeliness}]\[Equal]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*)
size:=Length[communitysize];(*gives size a value equal to the number
of elements in communitysize*)
generations=1000000;(*time steps that the funtion runs which is given
as size squared; this excepted time to monodomince*)
hubl[group_]:= group[[Random[Integer,{1,size}]]] ;(*takes a random
element of group*)
metareplace:=(communitysize[[Random[Integer,
{1,size}]]]=hubl[metacommunity]);
(*takes random element of community size and replaces it with random
element of metacommunity by way of the function hubl[group_]*)
community:= (communitysize[[Random[Integer,
{1,size}]]]=hubl[communitysize]);
(*takes a random element of communitysize and replaces it with another
random element of community size by way of the function
hubl[group_]*)
speciation:=(hubl[communitysize]=Random[Integer,{size+1,size+100}]);
(*creates a function that produces a random integer from 11 to 110*)
immigration:=If[metachance,metareplace,community];
(*asks if metachance is true. if it is true, runs metareplace if not
it runs community*)
changing:=If[chance,speciation,immigration ];
(*makes new vector by replacing random elements of communitysize by
way of the function speciation if the function chance is true or by
way of the function immigration if chance is false*)
SpeciesCount[lyst_]:= Length[Split[Sort[communitysize]]]; (*counts the
number groupings of like values there are in communitysize. it does
this by sorting elements together then Split takes identical elements
and puts them in sublist then Length counts the sublist*)
randomwalks:=Table[changing;{t,SpeciesCount[communitysize]},{t,
1,generations}];
(*creates a table of the function SpeciesCount from time step 1 till
generation*)
lyst = randomwalks;
averagespecies:=N[Mean[Map[Last,lyst]]];
(*function produces the mean from SpeciesCount of communitysize over
the
total time steps*)
halfaveragespecies:=N[Mean[Last/@Take[lyst,{generations/2}]]];
(*function produces the mean from SpeciesCount of communitysize over
half the total time steps*)
Print[lyst,{averagespecies},
{halfaveragespecies}];ListPlot[lyst,AxesLabel[Rule]
{"Generations","Number of Species"}]
THANKS!
Prev by Date:
**Re: averaging sublists of different lengths**
Next by Date:
**Re: Re: Re: Re: Re: RE: Re: Sometimes <space> means multiple**
Previous by thread:
**Mathematica SIG (Northern Virginia and Washington DC)**
Next by thread:
**GUI kit basic instructions**
| |