- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
find multiple peak values in a column
Hello,
I am working a data table that have time and length, and the length data is like wave. I want to find peak value of length of each wave, and label the time when the peak happens in a new column as "peak".
Can someone take a look and help me with the script?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
Here is a new column in your data table that detects peaks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
A lot of thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
Hello Super TxNelsol,
I am pleased to greet you, a query:
Attached a table with 200 columns of high and low stock prices, I would like to create new columns that indicate or place 1 for lower prices and -1 for the highest prices (peaks), 0 for the rest of prices.
Close (200) - 1.18076
Close (199) - 1.18073
Close (198) - 1.18071
Optimal signal1: -1
Optimal signal2: 0
Optimal signal3: 0
Close (200) - 1.18056
Close (199) - 1.18056
Close (198) - 1.18057
Optimal signal1: 0
Optimal signal2: 0
Optimal signal3: 0
Close (200) - 1.18094
Close (199) - 1.18077
Close (198) - 1.1805
Optimal signal1: 0
Optimal signal2: 0
Optimal signal 3: 1
Greetings,
Marco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
Scoping the Attachment 200 column table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
See if this works the way you are thinking
Names Default To Here( 1 );
dt = Current Data Table();
colCount = N Cols( dt );
// Loop across all of the columns
For( i = 1, i <= colCount, i++,
// Create the new column and set all values to 0
dt << New Column( "Optimal signal" || Char( i ), set each value( 0 ) );
// Get the name of the column to work on
theColName = Column( dt, i ) << get name;
// Find all of the High Points
Eval(
Parse(
"theRows = dt<<get rows where(lag(:\!"" || theColName || "\!"n,1) <= :\!"" || theColName
|| "\!"n & lag(:\!"" || theColName || "\!"n,-1) <= :\!"" || theColName ||
"\!"n |
(row()==1 & lag(:\!"" || theColName || "\!"n,-1) <= :\!"" || theColName ||
"\!"n) |
(row()==N Rows(dt) & lag(:\!"" || theColName || "\!"n,1) <= :\!"" ||
theColName || "\!"n)
);"
)
);
// Set the found rows to -1
If( N Rows( theRows ) > 0,
Column( dt, N Cols( dt ) )[theRows] = -1
);
// Find all of the Low Points
Eval(
Parse(
"theRows = dt<<get rows where(lag(:\!"" || theColName || "\!"n,1) >= :\!"" || theColName
|| "\!"n & lag(:\!"" || theColName || "\!"n,-1) >= :\!"" || theColName ||
"\!"n |
(row()==1 & lag(:\!"" || theColName || "\!"n,-1) >= :\!"" || theColName ||
"\!"n) |
(row()==N Rows(dt) & lag(:\!"" || theColName || "\!"n,1) >= :\!"" ||
theColName || "\!"n)
);"
)
);
// Set the found rows to 1
If( N Rows( theRows ) > 0,
Column( dt, N Cols( dt ) )[theRows] = 1
);
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
Dear Jim,
I am new to JMP, could you please adapt the script to the attached table?
Greetings
Marco
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
Here is all you need to do
- Open the data table
- Go to File=>New=>Script This will open a blank script window
- Cut and past the script from the webpage into the Script Window
- Run the script by clicking on the
icon in the Script Window
That will run the script against the newly opened data table.
I strongly suggest that you take the time to read the Discovering JMP document available under the Help pull down menu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: find multiple peak values in a column
Hi Jim,
Super easy to apply the Script, but the objective is for a formula in each new column to find the highest stock prices (peaks) and place -1 and the lowest stock prices place 1 ... within a column range that I define (column range = 1-2 or 1-10 or 1-100 or 1-1000 ... etc), that is, in a hypothetical scenario using a history of stock prices ... what moments During the day they would have been optimal to buy shares at a lower price .... and ..... sell shares at times of higher price or rise ......, in such a way that it can train a neural network to learn to buy when the share price reaches its lowest point or 1 and sell when the share price reaches its highest point or -1 and when the price is with little movement the formula put 0
Greetings,
Marco