Skip to content

Making Connections

isee systems blog

Making Connections

  • About
  • More Connections
Search

Generating Random Numbers from Custom Probability Distributions

Updated: November 1, 2017May 29, 2014Filed under: Modeling Tips
  • STELLA & iThink
4 Comments

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:

image

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:

image

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.

(more…)

Modeling Tips, STELLA & iThink
  • builtins
  • distributions
  • graphical function
  • iThink/STELLA
  • probability
4 Comments

Generating Custom Reports Using XMILE

Updated: May 7, 2014September 4, 2013Filed under: Modeling Tips
  • STELLA & iThink
No comments yet

XMILE is an open standard for describing system dynamics models in XML.  Version 10 of iThink and STELLA output their models in the XMILE format.  One of the advantages of XML is that it is a text-based format that can be easily queried and manipulated.  This post will show you how to use XMLStarlet, a free XML command line management tool available for Windows, Macintosh, and Linux, to easily extract information from a XMILE model.  It will also demonstrate how to modify the XML style sheet (XSLT) generated by XMLStarlet to create custom HTML reports.

Our goal is to create a report that lists the stocks, flows, and converters in the susceptible-infected-recovered (SIR) model of infection shown below (available by clicking here).  Each model variable will be listed with its own equation and sorted by name.

SIR

XMLStarlet uses the select command (sel) for making queries to an XML file and formatting the results.  We will use all of the following select command options:

-t (template): define a set of rules (below) to be applied to the XML file
-m “XPath query” (match): find and select a set of nodes in the XML file
-s <options> “XPath expression” (sort): sort selected nodes by XPath expression
-v “XPath expression” (value): output value of XPath expression
-o “text” (output): output the quoted text
-n (newline): start a new line in the output

Reporting Stock Names

Let’s start by outputting the names of the stocks in the model.  In a XMILE file, stocks are identified by the <stock> tag, which is nested inside the <xmile> and <model> tags:

<xmile …>
   <model>
      <stock name="Infected">
         <eqn>1</eqn>
      </stock>
   </model>
</xmile>

There is one <stock> tag for every stock in the model and each stock has, at a minimum, both a name (in the “name” attribute) and an initialization equation (in the <eqn> tag).  To get the names of all stocks in the model, we can build a template using these XMLStarlet command options:

sel –t -m “_:xmile/_:model/_:stock” -v “@name” -n

The “sel” chooses the select command and the –t begins the template (the set of rules used to extract and format information from the XML file).  The –n at the end puts each stock name on its own line.

The –m option defines the XML path to any stock from the root.  In this case, the –m option is selecting all the XML nodes named stock (i.e., <stock> tags) that are under any <model> tags in the <xmile> tag.  From the XMILE file, one might expect the XML path to be “xmile/model/stock,” but the tags in the XMILE file are in the XMILE namespace and XPath, which is being used for this query, requires namespaces to be explicitly specified.  Luckily, XMLStarlet, starting in version 1.5.0, allows us to use “_” for the name of the namespace used by the XML file, in this case the XMILE namespace.  Thus, every XMILE name in a query must be preceded by “_:”.

Finally, the –v option allows us to output the name of each node selected with -m (stocks, in this case).  The “@” tells XPath that “name” is an attribute, not a tag, i.e., it is of the form name=”…” rather than <name>…</name>.

To build a full command, we need to add the path to XML Starlet to the beginning and the name of the XML file being queried to the end:

XMLStarlet_path/xml <options above> SIR.stmx

The entire command without the path to XMLStarlet is:

xml sel -t -m “_:xmile/_:model/_:stock” -v “@name” -n SIR.stmx

This command produces the following output:

Infected
Susceptible
Recovered

(more…)

Modeling Tips, STELLA & iThink
  • reports
  • XMILE
No comments yet

XMILE – An open standard for system dynamics models

Updated: August 26, 2013July 19, 2013Filed under: News & AnnouncementsNo comments yet

In June, isee systems and IBM sponsored a new technical committee in OASIS, a large standards organization. This committee is developing a new system dynamics modeling standard called XMILE. This blog post will answer some important questions about XMILE. 1. What is XMILE? XMILE is an open XML protocol for the sharing, interoperability, and reuse …

Keep Reading
News & Announcements
  • XMILE
No comments yet

Posts navigation

  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • …
  • 29
  • Next

Categories

  • Education (4)
  • isee NetSim (3)
  • isee.NET Framework (1)
  • Modeling Tips (32)
  • News & Announcements (15)
  • STELLA & iThink (14)
  • Stories from the Field (5)
  • Systems Thinking (8)
  • Training (6)

Archives

Browse by keyword

2D array archetypes arrays Barry Richmond Bass diffusion builtins calibration Causal Loop CLD command line conferences crisis data diffusion Education environment export game graphical function h1n1 healthcare housing import iThink/STELLA market dynamics MODSIM modules mortgage netsim optimization Physics policy price releases scholarship software spatial Stella storytelling System Dynamics Society Systems Thinking Version 9.1.2 video webinar workshop

Recent Posts

  • COVID-19: Modeling Distributions of Incubation and Recovery Times April 1, 2020
  • Multiobjective Optimization January 9, 2018
  • Optimizing Model Performance December 22, 2017
  • Calibration in Stella® December 15, 2017
  • Drifting Goals March 9, 2016

RSS System Dynamics Forum

Recent Comments

  • best apps review on About
  • digital software on Modeling the Economic Crisis
  • Mishawaka Indiana on What are “Mental Models”?
  • La Paz Indiana on XMILE – An open standard for system dynamics models
  • Bristol Indiana on Modeling the Economic Crisis

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Products
Software (v1.3)
  • Stella Architect
  • Stella Professional
  • Stella Designer
  • Stella Simulator
  • iThink
  • Feature Updates
  • Policies
  • Publishing Options
  • License Agreement
Free Software
  • Stella Online
  • isee Player
  • Stella Architect Trial
Solutions
Consulting
  • Systems Innovation Practice
Common Applications
  • Business
  • Education
  • Research
  • Government
  • Energy
  • Health
  • Agriculture
  • Manufacturing
  • Conservation
Quick Links
About
  • isee systems
  • Systems Thinking
  • Barry Richmond Scholarship
Resources
  • Frequently Asked Questions
  • Product Help
  • Examples
  • Request Support
  • Request Quote
  • Systems in Focus
  • Quick Tips
  • Legacy Tutorials
News and Events
Upcoming Workshops
  • Introduction to Dynamic Modeling
  • Whole Systems Partnership
Newsletter
  • The Connector
Recent Webinars
  • Model Mysteries
Recent Training
  • Systems Thinking Practice
Press Release
  • Stella Architect Release

  Phone: (603) 448-4990   Email: info@iseesystems.com

   Monday - Friday: 9:00 am - 5:00 pm EDT | Saturday - Sunday: Closed
Wheelock Office Park | 31 Old Etna Rd, Suite 7N | Lebanon, NH 03766 | US

isee systems inc. holds registered trademark rights over the following: iThink®, STELLA®, Stella®, isee systems® and claims the following trademarks; isee NetSim™, Stella Live™, Causal Lens™ and Stella Online™.

Terms of Use

© 2017. isee systems inc . All rights reserved.