Subscribe Bookmark RSS Feed

JSL Fit Distribution ( <type> )

fugalnc

Community Trekker

Joined:

Nov 12, 2015

I'm trying to create a distribution plot from a column of data and fit a continuous distribution to it. The type of distribution I want to fit is variable, but known within the script. I can't for the life of me figure out how to pass a variable as the type of distribution to fit in Fit Distribution()

 

So far I've tried

fit_type = "Normal";

Distribution(
	Column( :data ),
	Fit Distribution( fit_type )
);

As well as

fit_type = "Normal";

Distribution(
	Column( :data ),
	EvalExpr( Fit Distribution( Expr(fit_type) ) )
);

And even

fit_type = "Normal";
string_expr = "Fit Distribution ( " || fit_type || " )";

Distribution(
	Column( :data ),
	EvalExpr( Expr( string_expr ) )
);

 

But none of these work. Any ideas out there?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Here is one way to do it:

fit_type = "Normal";
Eval(
	Substitute(
			Expr(
				Distribution(
					Continuous Distribution( Column( :NPN1 ), Fit Distribution( __fit_type__ ) )
				)
			),
		Expr( __fit_type__ ), Parse( fit_type )
	)
);
Jim
2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Here is one way to do it:

fit_type = "Normal";
Eval(
	Substitute(
			Expr(
				Distribution(
					Continuous Distribution( Column( :NPN1 ), Fit Distribution( __fit_type__ ) )
				)
			),
		Expr( __fit_type__ ), Parse( fit_type )
	)
);
Jim
fugalnc

Community Trekker

Joined:

Nov 12, 2015

That works. Seems more convoluted than it should be.

 

I have a Distribution() window with multiple Continuous Distribution() in it, and putting the Substitute around it all works well.

 

Thanks!