Skip to main content
added 62 characters in body
Source Link
dr.blochwave
  • 8.8k
  • 3
  • 43
  • 76

Bug introduced in 10.0 and fixed in 10.1


MovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series.

But the error returned by the following code bothers me:

series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]

(* Power::infy: Infinite expression 1/0. encountered. >>\*)
(* {1, 1/2, 1/3, 1/4} *)

However, this code returns the result with no error:

MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]

(* {1, 1/2, 1/3, 1/4} *)

What causes this problem?

MovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series.

But the error returned by the following code bothers me:

series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]

(* Power::infy: Infinite expression 1/0. encountered. >>\*)
(* {1, 1/2, 1/3, 1/4} *)

However, this code returns the result with no error:

MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]

(* {1, 1/2, 1/3, 1/4} *)

What causes this problem?

Bug introduced in 10.0 and fixed in 10.1


MovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series.

But the error returned by the following code bothers me:

series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]

(* Power::infy: Infinite expression 1/0. encountered. >>\*)
(* {1, 1/2, 1/3, 1/4} *)

However, this code returns the result with no error:

MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]

(* {1, 1/2, 1/3, 1/4} *)

What causes this problem?

edited tags
Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
Tweeted twitter.com/#!/StackMma/status/566964997151260672

MovingMap isMovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient tool to calculatefor calculating the percentage changeschange of a series.

But one thingthe error returned by the following code bothers me is this error.:

series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]

The output is


(* Power::infy: Infinite expression 1/0. encountered. >>>>\*)
(* {1, 1/2, 1/3, 1/4} *)

However, this code returns the result with no error:

MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]

gives


(* {1, 1/2, 1/3, 1/4} *)

without an error.

I don't understand whatWhat causes thatthis problem.?

MovingMap is a very convenient tool to calculate the percentage changes of a series.

But one thing bothers me is this error.

series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]

The output is

Power::infy: Infinite expression 1/0. encountered. >>
{1, 1/2, 1/3, 1/4}

However,

MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]

gives

{1, 1/2, 1/3, 1/4}

without an error.

I don't understand what causes that problem.

MovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series.

But the error returned by the following code bothers me:

series = Range[5];
MovingMap[#[[2]]/#[[1]] - 1 &, series, {2}]

(* Power::infy: Infinite expression 1/0. encountered. >>\*)
(* {1, 1/2, 1/3, 1/4} *)

However, this code returns the result with no error:

MovingMap[f, series, {2}] /. f -> Function[#[[2]]/#[[1]] - 1]

(* {1, 1/2, 1/3, 1/4} *)

What causes this problem?

Source Link
Y. Kwon
  • 565
  • 2
  • 8
Loading