STELLA® and iThink® provide many useful probability distribution functions (listed here). However, sometimes you need to draw random numbers from a different probability distribution, perhaps one you have developed yourself. In these cases, it is possible to invert the cumulative probability distribution and use a uniformly distributed random number between zero and one (using the RANDOM built-in) to draw a number from the intended distribution. With a lot of math, this can be done analytically (briefly described here). With no math at all, it can be closely approximated using the graphical function.
Find the Cumulative Distribution Function
Every probability distribution has a probability density function (PDF) that relates a value with its probability of occurring. The most famous continuous PDF is the bell curve for the normal distribution:
From the PDF, we can see that the probability of randomly drawing 100 is just under 0.09 while the probability of randomly drawing 88 or 112 is close to zero. Note that applying the techniques described in this article to a continuous probability distribution will only approximate that distribution. The accuracy of the approximation will be determined by the number of data points included in the graphical function.
For discrete probability functions, the PDF resembles a histogram:
From this PDF, we can see that the probability of randomly drawing 1 is 0.4, while the probability of drawing 3 is 0.15. As discrete probability distributions can be represented exactly within graphical functions, the remainder of this article will focus on them.
Last week, we released version 1.1 of the isee NetSim software. isee NetSim enables iThink and STELLA users to publish their models online so anyone can run them in a web browser. Version 1.1 introduces several new features. In this post I will share a couple of those that I am most excited about.
Forio Simulate—Like YouTube for Simulations
Since the debut of the isee NetSim software we have collaborated with Forio Business Simulations to provide free hosting for models published online. Last year, I saw a demo of Forio’s new simulation service, Forio Simulate, in the early development stage. It was awesome. I couldn’t believe it—they added all of the Web 2.0 features I’d been dying for, and a slick, fun to use interface. I knew we had to make isee NetSim work with it.
The new service is social by nature—it features keyword tagging, ratings, comments and built-in model sharing. It’s like YouTube for simulations. You can browse simulations and games that others have created, find similar ones by keyword tags, and embed simulations on blogs or web pages. So you don’t have to be actively publishing your own simulations, or even be a modeler to get a lot of value from the site. In fact, it’s a great way to introduce people to modeling and simulation. Just post a link!
And if you are a modeler, you can get even more out of the service. Most of the simulations published to Forio Simulate allow you to download or copy the underlying model that powers it. Here at isee, we’ve uploaded the original iThink and STELLA models used to create all of our sample isee NetSim simulations. That way anyone can run the simulation online in a browser and download the source model to dig into if they want more. Take a look at isee systems’ models published on Simulate by clicking on the screen shot below.
The simulation overview page allows anyone to download the source model, rate, comment, add tags and embed the simulation on other web pages.
Anyone can use free hosting on Forio Simulate if the model contains 400 or fewer equations and is shared with other users of the service. If you want to protect the model, resell a simulation, use a custom URL, etc., you can sign up for a premium hosting plan. It’s easy to select a hosting plan when you upload your model with isee NetSim.
Graphical Input Device
Use the GID to change the price assumption
One of the most requested features for isee NetSim has been the graphical input device, or “GID” as we like to call it. GIDs offer a simple way to allow people running your simulation to change the model assumptions. Often it’s easier to sketch a curve of the behavior of a variable than to input numbers directly.
For example, the model below is a generic renewable-resource model that enables you to experiment with yield and price of a renewable-resource via GIDs. The model is from our “Thinking in Systems” online course. I published the model to Forio Simulate and then embedded it here. Click the “Review model” link to take a brief tour of the model.
You can change the price elasticity and “yield per unit capital” curve by first clicking on one of the GIDs. A window will pop open that displays the details of the curve. Click and drag within the grid to draw a new curve. Press “Ok” to apply the changes. Take a few moments to play around with the model below.
[Editor’s note: If you cannot see the embedded model below because you are reading this post in a feed reader or email, please visit the post page here]
What I find interesting after playing with this model is what happens when you start to push the yield up. At some point the efficiency improves to the point where the renewable-resource gets completely wiped out. Sometimes the inefficiencies of harvesting a resource can be a good thing—it gives the resource time to “catch up”. This may be a useful point to consider when thinking about sustainable systems. What happens when you make the resource inexpensive?
A GID for the web
You may have noticed that the GID within isee NetSim does not allow a user to type numbers to define data points or change the x and y ranges. We decided this simpler version of the GID was a good fit for models published to the web and would cover most use cases. The GID allows users to easily change the assumptions by sketching a behavior pattern and not really concern themselves with the data.
If you’ve been dying to publish models with GIDs online, now is your chance. While you’re at it, check out Forio Simulate and start contributing to the growing simulation community. You can download a trial of isee NetSim 1.1 here. If you already own isee NetSim, visit your “My Software” page on the isee systems website to download the upgrade.
Sometimes it is necessary to access a data set from multiple places within a model. For example, a manufacturer may have a non-linear curve that maps capacity required for a given product to raw material required to manufacture it. Such a curve is shown below:
If one production line needs to know this information, a graphical function works fine. However, if there are two production lines in the model, the second line also needs this information. If the two lines are identical in structure, the model could be arrayed to share the curve for both lines. If they are not, it was necessary in versions prior to 9.1 to make a copy of this curve for the second production line. Then if, at a later time, one copy of the curve needed to be changed, the other one also needed to be changed in the same way.
Version 9.1 introduced the LOOKUP built-in. This allows any graphical function curve to be re-used as many times as desired within the same model. Note that a graphical function, by definition, ties a specific equation to the given curve. Using LOOKUP, it is now possible to evaluate that same curve using several different equations in the same time step.
In this case, let’s assume the second production line has similar variables with “2” appended to their names. Thus, there is a capacity2 and a material needed 2. Prior to version 9.1, it was necessary for material needed 2 to be an identical copy of material needed.
Since version 9.1 allows the curve to be re-evaluated for any arbitrary
expression, material needed 2 no longer needs to be a graphical function.
Instead, it contains the equation:
Version 9.1.2 adds the ability to incorporate non-regularly sampled data easily into your models. Many people use the graphical function for historical records of data. The graphical function, however, assumes a fixed interval along the x-axis. This can make it difficult to use data like the following:
While it is easy to determine the fixed interval to use to capture all of these points (1 day), it is more difficult to determine what data points to use for the missing intermediate 1-day values. There are also many cases where it is very difficult to find a fixed interval that works for a given dataset.
Graphical Function Day (click for full size)
The LOOKUPXY built-in was specifically added to address this issue. It is unique in that it requires two separate graphical functions: one for the x-coordinates of each pair and one for the y-coordinates of each pair. The number of points in each graphical function should match; if they do not, extraneous points are ignored. The data values (x-coordinates and y-coordinates) are both entered by the user as the y-values in each graphical function. The x-values in each graphical function are ignored; only the number of points matter. It is a good idea, though, to run the x-axis of both from one to the number of points. That way, it is easy to verify that the values in each graphical function properly align with one another. In addition, the x-coordinates should be in increasing order. If they are not, however, the program will automatically readjust them when the model is first run.
One of the questions I am sometimes asked is, “If I need a specific x-value to appear in my graphical function, how do I determine the number of points required to include that exact point?” This arises because in a graphical function, the x-axis is divided into fixed intervals; the user is only allowed to specify x-min, x-max, and the number of data points. [If you really need a graphical function with arbitrary (x, y) points, use the LOOKUPXY() built-in function available in version 9.1.2.]
For the following discussion, the range on the x-axis will be needed:
range = x_max – x_min
In all of the examples below, x_min = 3.000 and x_max = 7.000, so the range = 7 – 3 = 4.
For integer values, here is a simple formula that always works:
# of data points = range + 1 (1)
For example (using the range above), if the number 6 (an integer) must appear as a point on the x-axis, 4 + 1 = 5 points will be needed. This divides the x-axis into the points 3.0, 4.0, 5.0, 6.0, and 7.0.
Fractional values, however, are more difficult. In general, if you can isolate the fractional part (and this evenly divides the range), the maximum number of points needed is given by this formula:
iThink and STELLA version 9.0 introduced a powerful new feature: data import and export with Excel. Here at isee, we were excited to hear from our customers about how much they appreciated the feature and how easy it was to use. In fact, many customers told us that it was the major reason they upgraded to version 9.0
Setting up a data import from Excel is pretty straight forward: type the name of the model variable in one cell, type the value you want to import in the cell below it, (or beside it if you are using horizontal orientation):
If you are importing a time series or graphical function, you just keep listing the data points in the cells below the variable name:
This kind of data formatting works well since an Excel sheet is made up of columns and rows. But how do you format data that is harder to visualize? Things get a little tricky when you start dealing with arrayed variables. The most complex import is a 2 dimensional array of graphical functions. It’s actually 3 dimensions!
I’ve put together a simple example to illustrate how to do this.