cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-275257%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3EMinimum%20mobile%20(fen%C3%AAtre%20mobile)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275257%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3EEst-ce%20que%20quelqu'un%20sait%20comment%20calculer%20un%20minimum%20mobile%20(ou%20d'ailleurs%20comment%20s%C3%A9lectionner%20%3CSPAN%3Ede%20mani%C3%A8re%20it%C3%A9rative%3C%2FSPAN%3E%20un%20nombre%20X%20de%20lignes%20de%20d%C3%A9calage%20et%20leur%20faire%20quoi%20que%20ce%20soit%2C%20comme%20calculer%20un%20minimum%2C%20un%20maximum%2C%20une%20plage%2C%20etc.%20Dans%20cet%20exemple%20sp%C3%A9cifique%2C%20je%20veux%20revenir%20sur%20dites%20les%20100%20derni%C3%A8res%20lignes%20et%20obtenez%20la%20valeur%20minimale%2C%20puis%20passez%20%C3%A0%20la%20ligne%20suivante%20et%20faites%20la%20m%C3%AAme%20chose%20(encore%20et%20encore).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-275257%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CLINGO-LABEL%3EConception%20d'exp%C3%A9riences%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-275287%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Minimum%20mobile%20(fen%C3%AAtre%20mobile)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275287%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEst-ce%20que%20quelque%20chose%20comme%20%C3%A7a%20fonctionnerait%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20default%20to%20here(%201%20)%3B%0Adt%20%3D%20open(%22%24SAMPLE_DATA%5CBig%20Class.jmp%22)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22Min%20height%205%20back%22%2C%20%0A%20Formula(%0A%20%20Min(%20%2F%2F%20since%20we%20want%20a%20minumum%20%0A%20%20%20%3Aheight%5B%2F%2F%20the%20column%20we%20want%20the%20minimum%20of%0A%20%20%20%20%2F%2F%20a%20slice%20of%20the%20current%20row%20minus%205%20(minimum%201%20so%20it's%20still%20on%20the%20datatable)%0A%20%20%20%20%2F%2F%20and%20current%20row%0A%20%20%20%20Min(%20Row()%20-%205%20)%3A%3ARow()%20%0A%20%20%20%5D%20%0A%20%20)%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-275272%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Minimum%20mobile%20(fen%C3%AAtre%20mobile)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275272%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELa%20macro%20ci-dessous%20n'est%20pas%20particuli%C3%A8rement%20%C3%A9l%C3%A9gante%2C%20mais%20fera%20l'affaire.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EFor%20(%20i%3D%20100%2C%20i%20%26lt%3B%3D%20N%20Rows%20(%20dt%20)%2C%20i%2B%2B%2C%0A%0A%20dt%20%26lt%3B%26lt%3B%20Select%20Rows%20(Index%20(i-99%2C%20i))%3B%0A%20%0A%20dt%20%26lt%3B%26lt%3B%20Subset(%0A%20Selected%20Rows(%201%20)%2C%0A%20Selected%20Columns%20(%200%20)%2C%0A%20Output%20Table%20(%22out%22)%0A)%3B%0A%0ACurrent%20Data%20Table%20(%20Data%20Table%20(%22out%22))%3B%0A%0Ax%20%3D%20Col%20Minimum%20(%20%3AYourDataColumn%20)%3B%0A%0AClose%20(%20Data%20Table%20(%20%22out%22)%2C%20no%20save)%3B%0A%0AColumn%20(%20%20%22YourMovingWindow%22%20)%5Bi%5D%20%3D%20x%3B%0A%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ESous-r%C3%A9gler%20les%20donn%C3%A9es%20s%C3%A9lectionn%C3%A9es%2C%20comme%20je%20l'ai%20fait%2C%20est%20lent.%20Peut-%C3%AAtre%20qu'un%20autre%20utilisateur%20a%20une%20meilleure%20id%C3%A9e%20de%20la%20fa%C3%A7on%20d'acc%C3%A9der%20aux%20donn%C3%A9es%20s%C3%A9lectionn%C3%A9es%20et%20d'extraire%20le%20produit%20souhait%C3%A9.%3C%2FP%3E%3CP%3EJe%20me%20demande%20%C3%A9galement%20%C3%A0%20quoi%20pourrait%20ressembler%20une%20formule%20de%20colonne%20pour%20obtenir%20les%20r%C3%A9sultats%20sans%20macro.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAcclamations%2C%3C%2FP%3E%3CP%3EKofi%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
RVhydrA
Level III

Moving minimum (moving window)

Does anyone know how to calculate a moving minimum (or for that matter how to iteratively select X number of lag rows and do anything to them such as calculate a min, max, range, etc. In this specific example i want to look back over say the last 100 rows and get the minimum value, then move to the next row down and do the same again (over and over). 

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: Moving minimum (moving window)

Would something like this work?

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");

dt << New Column("Min height 5 back", 
	Formula(
		Min( // since we want a minumum 
			:height[// the column we want the minimum of
				// a slice of the current row minus 5 (minimum 1 so it's still on the datatable)
				// and current row
				Min( Row() - 5 )::Row() 
			] 
		)
	)
);
Vince Faller - Predictum

View solution in original post

2 REPLIES 2
Monomorphist
Level III

Re: Moving minimum (moving window)

The macro below isn't particularly elegant, but will do the job. 

 

For ( i= 100, i <= N Rows ( dt ), i++,

 dt << Select Rows (Index (i-99, i));
 
 dt << Subset(
	Selected Rows( 1 ),
	Selected Columns ( 0 ),
	Output Table ("out")
);

Current Data Table ( Data Table ("out"));

x = Col Minimum ( :YourDataColumn );

Close ( Data Table ( "out"), no save);

Column (  "YourMovingWindow" )[i] = x;

)

Sub-setting the selected data, the way I've done it, is slow. Perhaps another user has a better idea how to access the selected data and extract the desired product.

I also wonder how a column formula could look like to achieve the results without a macro.

 

Cheers,

Kofi

vince_faller
Super User (Alumni)

Re: Moving minimum (moving window)

Would something like this work?

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");

dt << New Column("Min height 5 back", 
	Formula(
		Min( // since we want a minumum 
			:height[// the column we want the minimum of
				// a slice of the current row minus 5 (minimum 1 so it's still on the datatable)
				// and current row
				Min( Row() - 5 )::Row() 
			] 
		)
	)
);
Vince Faller - Predictum