Series Progression

Is there any package to determine series progression in R?
like Arithmatic progression,Geometric progression,Harmonic,fourier series..etc..

i want to know weather a vector say as
v<-1,2,3,4... is in arithmatic progression by differencing 1
like wise i want for all mathematic series ....

in other word i want to mine number pattern in R for large dataset.

I don't know whether there are any packages or not. But for AP, Gp or HP, this shouldn't be too difficult.

# defining functions to check AP, GP or HP
is_AP <- function(given_sequence)
{
  successive_differences <- diff(x = given_sequence)
  ifelse(test = (length(x = unique(x = successive_differences)) == 1),
         yes = TRUE,
         no = FALSE)
}

is_GP <- function(given_sequence)
{
  successive_ratios <- sapply(X = 2:length(x = given_sequence),
                              FUN = function(t)
                              {
                                given_sequence[t] / given_sequence[t - 1]
                              })
  ifelse(test = (length(x = unique(x = successive_ratios)) == 1),
         yes = TRUE,
         no = FALSE)
}

is_HP <- function(given_sequence)
{
  reciprocal_sequence <- (1 / given_sequence)
  is_AP(given_sequence = reciprocal_sequence)
}

# examples
ap_example <- seq(from = 1,
                  to = 19,
                  by = 2)
gp_example <- 2 ^ (1:10)
hp_example <- (1 / (1:10))

is_AP(ap_example)
#> [1] TRUE
is_GP(ap_example)
#> [1] FALSE
is_HP(ap_example)
#> [1] FALSE
is_AP(gp_example)
#> [1] FALSE
is_GP(gp_example)
#> [1] TRUE
is_HP(gp_example)
#> [1] FALSE
is_AP(hp_example)
#> [1] FALSE
is_GP(hp_example)
#> [1] FALSE
is_HP(hp_example)
#> [1] TRUE

Created on 2019-02-09 by the reprex package (v0.2.1)

Obviously, we don't need to check all differences or ratios. You can modify suitably.

I don't think that real life datasets will represent such simple patterns. You'll need to plot and check for patterns visually.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.