[Date Index]
[Thread Index]
[Author Index]
Re: A program check
*To*: mathgroup at smc.vnet.net
*Subject*: [mg75953] Re: A program check
*From*: "JGBoone at gmail.com" <JGBoone at gmail.com>
*Date*: Mon, 14 May 2007 03:31:42 -0400 (EDT)
*References*: <200705030748.DAA17368@smc.vnet.net><f1eqi9$568$1@smc.vnet.net>
On May 4, 12:23 am, anguz... at ing.uchile.cl wrote:
> Hello.
> I think it's fine, just two comments:
>
> > speciation:=(hubl[communitysize]=Random[Integer,{size+1,size+100}]);
> > (*creates a function that produces a random integer from 11 to 110*)
>
> Why these numbers?
>
> > 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*)
>
> SpeciesCount doesn't use the lyst_ replacement in its definition. I'd
> define instead:
>
> > SpeciesCount[lyst_]:= Length[Split[Sort[lyst]]];
>
> Do you see a problem with your implementation?
>
> Atte. Andres Guzman
>
> "JGBo... at gmail.com" <JGBo... at gmail.com> ha escrito:
>
>
>
> > 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!
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
i don't quite understand your first question. But i need to rewrite
that line anyway. I want it to put in a new number every time its
called up. I realize now that there is a possibility for numbers to be
put in more than once.
the answer to the second question is yes i understand that now. i just
learned mathematica this semester and ran this simulation model. so it
was really a first attempt at anything serious.
Prev by Date:
**Re: Package Help in Mathematica 6**
Next by Date:
**Re: Package Help in Mathematica 6**
Previous by thread:
**Re: A program check**
Next by thread:
**Re: A program check**
| |