Subscribe Bookmark RSS Feed

Inverse GLog

Martin

Community Trekker

Joined:

Aug 13, 2013

I am trying to get the Inverse of the GLog function. Is there way to export the formula for this?

3 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

I am not aware of such.  What I have used in the past, is a little piece of JSL that uses a B Tree Lookup to do close approximations to determine the result.

Jim
Martin

Community Trekker

Joined:

Aug 13, 2013

Thanks. I am currently transferring the formula to Excel and using the Goal Seek to perform the finding. With so many other functions in JMP having a Save Inverse Function, too bad GLog does not!
Oh well.
Thanks again Jim.
txnelson

Super User

Joined:

Jun 22, 2012

Here is a little script that creates the will return a untransformed value from a saved transformed formula.  Tell me if this is something you think is useful

Names Default to Here( 1 );
dt=open("$SAMPLE_DATA\semiconductor Capability.jmp");
Dis =dt << Distribution(invisible,
	Continuous Distribution(
		Column( :NPN1 ),
		Fit Distribution(
			GLog(
				Spec Limits(
					LSL( 104.412948990151 ),
					USL( 131.893493064355 ),
					Target( 118.153221027253 )
				)
			)
		)
	),
	SendToReport(
		Dispatch(
			{"NPN1"},
			"Distrib Histogram",
			FrameBox,
			{DispatchSeg( LabelSeg( 4 ), {Font( "Arial Unicode MS", 9, "Plain" )} ),
			DispatchSeg( LabelSeg( 5 ), {Font( "Arial Unicode MS", 9, "Plain" )} ),
			DispatchSeg( LabelSeg( 6 ), {Font( "Arial Unicode MS", 9, "Plain" )} )}
		)
	)
);
Dis<< Fit Distribution( GLog( Save Transformed ) );
Dis << Delete Window;
Wait(0);
RawFormula = "";
RawFormula = char(column(N Cols(dt))<<get formula);
ColName = "NPN1";
Target = -0.0890560572933256;
/***********************************************************************/
/*                                                                     */
/* The getformula column retrieves the formula from the translation    */
/* column and replaces the Original Column name in the formula with    */
/* string "__value__".  The value of this variable is what will be     */
/* evaluated in the successive approximations done by the script.      */
/*                                                                     */
/***********************************************************************/

getformula = Function( {ColName, RawFormula},
	TheFormula = uppercase(RawFormula);
	// Check to see that a formula was found
	If( Is Empty( TheFormula ) == 1,
		Dialog(
			"   The column specified as",
			"the Transformed Column does",
			"      not contain a formula. ",
			" ",
			"    Please rerun and select",
			"       the correct column"
		);
		Throw();
	);

	// Get the actual name of the orignal column since
	// the upper,lower case and spacing is critical in determining
	// where in the formula the column name actually occurs
	//ColName = Column( ColName ) << Get Name;

	// Determine if the reference to the column name in the 
	// formula is a simple :colname reference or a complex
	// reference :Name(\!"colname\!")
	// If the column name isn't found set the return code to -1
	If(
		Contains( TheFormula, ":" || ColName ), ColonColName = ":" || ColName//
	, // Else
		Contains( TheFormula, ":Name(\!"" || ColName || "\!")" ), ColonColName = ":Name(\!"" || ColName || "\!")"//
	, // Else
		rc = -1
	);
		
	// Replace all of the column references in the formula with
	// the string "(__value__)" so that when the formula is 
	// evaluated later, it will take the then value of the memory
	// variable called __value__ and use it in the formula
	If( Contains( TheFormula, ColonColName ) > 0,
		While( Contains( TheFormula, ColonColName ) > 0, TheFormula = Munger( TheFormula, 1, ColonColName, "(__Value__)" ) ),
		Dialog(
			"   The column specified as",
			"the Transformed Column does",
			"     not contain a reference",
			"      to the original column.",
			"           in it's formula.",
			" ",
			"    Please rerun and select",
			"       the correct column"
		);
		Throw();
	);
	TheFormula;
);

/***********************************************************************/
/*                                                                     */
/* The gettrans function evaluates the formula in the transformed      */
/* and converts the formula into a generic form for repeated use in    */
/* running of the script.                                              */
/*                                                                     */
/***********************************************************************/

gettrans = Function( { ColName,RawFormula,TheTarget},
	{TheFormula, High, Low, TheTarget, TheMax, Themin, __value__}, 
	
	TheFormula = getformula(ColName,RawFormula);
	// The program uses successive approximations to determine the different 
	// parametrics.  The way it works is that it calculates the needed parameter
	// such as Mean, or Standard Deviation, and then by using successive 
	// approximations from the original column's values, and passing those
	// values through the columns formula, when the approximation value matches
	// the calculated value from the transformed column, the retransformed value
	// has been found

	// Set the extreem valuesH
	High = 999999999999999999999999;
	Low = -999999999999999999999999;
	
	// Check to see if negative values fail
	__value__= -1;
	if(isMissing(try(eval(parse(theformula)),.))==1,Low=0;);
	
	// Make a guess at the first value 
	__value__ = Mean( High, Low );

	// Iterate the guessing for up to 100 times, adjusting by 1/2 on each loop
	For( i = 1, i <= 100, i++,
		TheResult = Eval( Parse( theformula ) );

		If(
			TheResult > TheTarget, High = __value__,
			TheResult < TheTarget, Low = __value__,
			Break()
		);
		If( High == Low, Break() );
		__value__ = Mean( High, Low );
	);
	
	__value__; // Expose the return value
); // End of function gettrans

trans=gettrans(ColName,rawformula,Target);

show(column(dt,ColName)[1],trans);
Jim