Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

C++ R Studio Envelope Function Help

Dorles123

New Coder
Hey y'all,

Not exactly C++ but I heard the R IDE is based off of it so please help 🙂

I'm working with a data set that looks like so
R_Data.png

I've tried everything to get the envelope function (esentially a function that estimates the the outside function containing the points) but have no idea where to go from here.
Code:
my_data <- read.delim(file.choose("pipe2a_00.txt"),sep=",")
t <- as.numeric(unlist(head(my_data[c(1)],20000)))
y <- as.numeric(unlist(head(my_data[c(2)],20000)))

ssp <- spectrum(y)
per <- 1/ssp$freq[ssp$spec==max(ssp$spec)]

plot(t, y, type='p')

reslm2 <- lm(ev ~ sin(2*pi/per*t)+cos(2*pi/per*t)+sin(4*pi/per*t)+cos(4*pi/per*t))
summary(reslm2)
lines(fitted(reslm2)~t,col='red')


This is what I have to far, and using reslm2 works amazing once I have points that correlate because it uses a second harmonic of sine and cosine waves, but my issue is I would need only the outer values and none of the inner values. This is for work with non-destructive evaluation so I would doing it on hundreds of thousands if not millions of points, so it needs to be able to run quickly, if anyone has any advice please let me know, I'd love to hear solution!
 
Last edited:

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom