Jump to content

How to create a lognormal distribution in Spotfire.


Natsuki Nakagawa

Recommended Posts

  • 1 month later...
  • 1 month later...

Creating a Log-Normal Distribution plot in Spotfire isvery do-able, just not "out-of-the-box"; it requires configuration and the use of a simple data function (see below).

Spotfire has an 'auto-bin' function that allow the creation of a Distribution of Normal Data; but that data is in linear scale. When the data is in log scale, the current (Spotfire v10.8) 'auto-bin' does not know how to return the correct "bins" for data that is log-scale and therefore displays the expected distribution (brar chart) incorrectly.

I order to correct for this you have to send the data to a TERR data function (script below) that will return the correct log distributed bins into a property. This property can be used in the bar charts' x-axis' expression in conjunction with the BinBySpecificLimits().

Here is an example where the column [myData] is Real() and is lognormally distributed. The property '${analyzeLogBins}' holds the returning string value from the TERR data function.

my example (attached image):

y-axis: count()x-axis: BinBySpecificLimits([myData],${analyzeLogBins}) as [Gross Amt]

TERR data function:

# Parameters:

# X - input; column of data

# Y - output; string value

if(length(X)>0){

lb = log10(min(X))

if (is.na(lb) | (min(X)==0)) {

lb = 0.00000001

} else{

lb = log10(min(X))

}

 

myout = exp(log(10)*seq(lb,log10(max(X)),length.out = userBins))

Y = toString(round(myout,digits=2))

}else{

Y='0'

}

Hope this helps you in creating your log-normal distribution plot. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...