Re: [R] Farey sequences

From: Greg Snow <greg.snow_at_ihc.com>
Date: Tue 08 Mar 2005 - 05:50:08 EST


This sequence of commands replicates your example, could you expand this to do what you want?

> tmp <- c( outer( 0:4, 1:4, "/") )
> tmp <- tmp[tmp <= 1]
> tmp <- unique(tmp)
> tmp <- sort(tmp)
> library(MASS)
> fractions(tmp)

[1] 0 1/4 1/3 1/2 2/3 3/4 1

Greg Snow, Ph.D.
Statistical Data Center
greg.snow@ihc.com
(801) 408-8111

>>> Robin Hankin <r.hankin@soc.soton.ac.uk> 03/04/05 07:06AM >>> Hi

has anyone coded up Farey sequences?

[
The Farey sequence of order "n" is the set of rational numbers i/j with (i,j)=1 such that 0 <= i,j <= n; the sequence is ordered from lowest to highest.
Thus

Farey_4 = {0/1 , 1/4 , 1/3 , 1/2 , 2/3 , 3/4 , 1/1} ]

My motivation is unimodular transformations: I need to systematically generate 2-by-2 integer matrices with determinant 1, and Farey sequences
seem to be the best way to do this.

--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Mar 08 05:58:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:41 EST