You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the FSharp.Stats.Signal.PeakDetection.SecondDerivative.getPeaks function for the 1st polynomial order in combination with the second derivative, it results in an "System.IndexOutOfRangeException: Index was outside the bounds of the array." - error.
To Reproduce
Steps to reproduce the behavior:
I looked into the code and tried to narrow the origin of the error down and found it was the fault of the
Signal.Filtering.savitzky_golay function used for calculating the second derivative and for data smoothing.
openFSharp.Stats///a = height of the gaussians peak, b = mean of gaussian distri, c = sigma of gaussian distribution,///x = window on x -axisletgaussianFunctionForY height mean sigma x = height*(exp(-((x-mean)**2.)/(2.*(sigma **2.))))letXX=[|0...0.1..100.|]letgaussianYY= XX |> Array.map (fun x -> gaussianFunctionForY 50.30.0.3 x)
getPeaks 0.15 XX gaussianYY ///error seen aboveletsmoothedData=
Signal.Filtering.savitzky_golay 5101 gaussianYY
|> Array.ofSeq ///no error, works as intended
Signal.Filtering.savitzky_golay 5121 smoothedData ///error seen above
Signal.Filtering.savitzky_golay 5121 gaussianYY ///error seen above
Signal.Filtering.savitzky_golay 5111 gaussianYY //no error
Signal.Filtering.savitzky_golay 5221 gaussianYY //no error
Apparently, the savitzky_golay function gives an error at the following line, but i am not 100% sure if i read the debugger correctly.
kMutagene
changed the title
getPeaks gives error when calculating 1st polynomial order
[BUG] getPeaks gives error when calculating 1st polynomial order
Feb 28, 2019
The reason for the error is, that the pseudoinvers matrix b has just 2 rows and by setting the derivative to 2 you aim to access the non existing row number 3.
let deriv =2
let m = (Algebra.LinearAlgebraManaged.pseudoInvers b).Row(deriv) * ((float(rate)**float(deriv)) * SpecialFunctions.Factorial.factorial(deriv))
Explanation of this behaviour:
A first order polynomial takes the form f(x)=ax+b. The first derivative is f'(x)=a and consequently the second derivative is f''(x)=0, and therefore cannot be accessed.
I do not think that it is a good idea (and invalid), to use the savitzky golay filter with these parameters.
Describe the bug
When using the FSharp.Stats.Signal.PeakDetection.SecondDerivative.getPeaks function for the 1st polynomial order in combination with the second derivative, it results in an "System.IndexOutOfRangeException: Index was outside the bounds of the array." - error.
To Reproduce
Steps to reproduce the behavior:
I looked into the code and tried to narrow the origin of the error down and found it was the fault of the
Signal.Filtering.savitzky_golay function used for calculating the second derivative and for data smoothing.
Apparently, the savitzky_golay function gives an error at the following line, but i am not 100% sure if i read the debugger correctly.
Expected behavior
Should smooth data, while trying to fit the data to first order polynomials on second derivative.
OS and framework information (please complete the following information):
Additional context
I am using the FSharp.Stats developer branch
The text was updated successfully, but these errors were encountered: