MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: buliding on functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79210] Re: [mg79176] Re: buliding on functions
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sat, 21 Jul 2007 04:24:40 -0400 (EDT)
  • References: <f7f2pb$o7k$1@smc.vnet.net> <f7hs43$s7c$1@smc.vnet.net> <22129174.1184937260899.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

I see at least four likely problems:

1) orspecies is used in hubl, but never defined.

2) The first iterator in randomwalks is preceded by a semicolon, so it  
ISN'T an iterator.

3) randomwalks takes a single argument, not three. (Try  
randomwalks/@{Q,R,S}, perhaps.)

4) In the "changing" function, you have speciation[group]... but  
speciation is an integer, not a function.

Bobby

On Fri, 20 Jul 2007 02:28:22 -0500, JGBoone at gmail.com <JGBoone at gmail.com>  
wrote:

> 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.
>
>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Re: Trouble with FindRoot
  • Next by Date: Re: two integrals
  • Previous by thread: Re: Re: buliding on functions
  • Next by thread: Cascaded (Multi-range) Iterators?