[Date Index]
[Thread Index]
[Author Index]
Re: A program check
*To*: mathgroup at smc.vnet.net
*Subject*: [mg75530] Re: [mg75505] A program check
*From*: anguzman at ing.uchile.cl
*Date*: Fri, 4 May 2007 04:15:05 -0400 (EDT)
*References*: <200705030748.DAA17368@smc.vnet.net>
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
"JGBoone at gmail.com" <JGBoone 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.
Prev by Date:
** Re: Gauss-Kronrod algorithm**
Next by Date:
**Re: Gauss-Kronrod algorithm**
Previous by thread:
**Re: GUI kit basic instructions**
Next by thread:
**Re: A program check**
| |