[R] [FORGED] Newbie Question on R versus Matlab/Octave versus C

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Tue Jan 29 08:33:46 CET 2019


On 1/28/19 4:00 PM, Alan Feuerbacher wrote:
> On 1/28/2019 4:20 PM, Rolf Turner wrote:
>>
>> On 1/29/19 10:05 AM, Alan Feuerbacher wrote:
>>
>>> Hi,
>>>
>>> I recently learned of the existence of R through a physicist friend 
>>> who uses it in his research. I've used Octave for a decade, and C 
>>> for 35 years, but would like to learn R. These all have advantages 
>>> and disadvantages for certain tasks, but as I'm new to R I hardly 
>>> know how to evaluate them. Any suggestions?
>> >
> snpped
>> * The syntax of R meshes beautifully with *my* thought patterns; YMMV.
>>
>> * Why not just bog in and try R out?  It's free, it's readily available,
>>    and there are a number of good online tutorials.
>
> I just installed R on my Linux Fedora system, so I'll do that.
>
> I wonder if you'd care to comment on my little project that prompted 
> this? As part of another project, I wanted to model population growth 
> starting from a handful of starting individuals. This is exponential 
> in the long run, of course, but I wanted to see how a few basic 
> parameters affected the outcome. Using Octave, I modeled a single 
> person as a "cell", which in Octave has a good deal of overhead. The 
> program basically looped over the entire population, and updated each 
> person according to the parameters, which included random statistical 
> variations. So when the total population reached, say 10,000, and an 
> update time of 1 day, the program had to execute 10,000 x 365 update 
> operations for each year of growth. For large populations, say 
> 100,000, the program did not return even after 24 hours of run time.
>
> So I switched to C, and used its "struct" declaration and an array of 
> structs to model the population. This allowed the program to complete 
> in under a minute as opposed to 24 hours+. So in line with your 
> comments, C is far more efficient than Octave.
>
> How do you think R would fare in this simulation?
>
This sounds like a problem that would fit into a stochastic differential 
equation.  There are at least three packages in CRAN (and I suspect a 
few more) that will handle simulations of stochastic differential 
equations. Bert's suggestion to use Rseek should serve you well.


-- 

David.



More information about the R-help mailing list