 <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.analytica.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bbecane</id>
	<title>Analytica Docs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.analytica.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bbecane"/>
	<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php/Special:Contributions/Bbecane"/>
	<updated>2026-05-19T16:10:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48570</id>
		<title>Multithreaded evaluation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48570"/>
		<updated>2016-08-24T14:44:03Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Concepts]]&lt;br /&gt;
''new to [[Analytica 5.0]]''&lt;br /&gt;
&lt;br /&gt;
''Requires [[Analytica Professional]]''&lt;br /&gt;
&lt;br /&gt;
Some computations can take advantage of multiple cores on your computer to speed up to net computation time. These computations partition the task across multiple threads, where each thread can be assigned to a different core. For example, when adding two large arrays, &amp;lt;code&amp;gt;A+B&amp;lt;/code&amp;gt;, where each array has 100,000 elements, the computation might be parallelized across four threads, with each thread handling roughly 25,000 additions each. As a result, the elapsed time to complete the full array addition might be as much as four times faster than it would have been when evaluated in single threaded mode.  Because there is additional overhead required to partition a task and coordinate multiple threads, the actual speedup will end up being something less that the total number of threads.&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation uses fine-grained parallelism, meaning that certain low-level computations are parallelized. The computation is decomposed at a high-level. So when concurrent evaluation is occurring, all threads are working on the same task.&lt;br /&gt;
&lt;br /&gt;
Not all operations are decomposed into parallel computation. In general, arithmetic operations are performed concurrently, but only when the arrays are large enough to justify the extra overhead of multithreading. As a rough idea, operators involving arrays  with fewer than 100 elements will be evaluated on a single thread, operations involving more than 1,000 cells are likely to be performed on multiple threads (if threads are available), and between there the threshold depends on the internal array structure, specific operation, etc.  Several built-in functions operate in parallel, as well as some internal bookkeeping, but again, these use multiple threads only when the arrays involved are large enough to justify the overhead. With new releases of Analytica, additional functions or operations may be enhanced to leverage multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation requires [[Analytica Professional]] or better.  It is not available in [[Analytica Free 101]]. &lt;br /&gt;
&lt;br /&gt;
By default, multithreaded evaluation is disabled in 32-bit Analytica, and it is recommended that you use single threaded evaluation in 32-bit Analytica, since the extra threads consume memory, and is 32-bit Analytica the extra memory space saved by using single-threaded evaluation is usually more important than the speed-ups from multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The configuration of multithreaded evaluation is controlled by two system variables. To change these, navigate the menus to [[Definition menu|Definition]] &amp;gt; System variables &amp;gt; Settings'''.  &lt;br /&gt;
&lt;br /&gt;
=== Max Evaluation Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation, or to a number greater than 1, up to the number of available cores on your computer, to allow multithreaded evaluation. Evaluation will limit the number of threads actually used to this number.&lt;br /&gt;
&lt;br /&gt;
This setting is specific to your computer, and not associated with any model. It persists when you quit and restart Analytica.&lt;br /&gt;
&lt;br /&gt;
If you want to prevent computations from periodically usurping all available cycles, you may opt to set this to a number less than the total number of cores on your computer.  If you are running multiple instances of Analytica or ADE, each may use up to this number of threads. Also, since each thread used does require extra memory, you might want to limit the maximum number of threads when you have a small amount of RAM on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Max Model Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation for the current model, or to 0 to eliminate any maximum number of threads. You can set it to a number greater than 1 to enforce a maximum number of threads that will be used for evaluation by the current model. The number of threads actually used for evaluation will never exceed this number.&lt;br /&gt;
&lt;br /&gt;
This setting is stored with the current model, and so will be set when you share your model with other people, but it won't impact other models.  &lt;br /&gt;
&lt;br /&gt;
Use this setting when you need to limit the number of threads used only for the current model. When Max Model Threads is set, the actual maximum number of threads used will be the smaller of Max Model Threads and Max Evaluation Threads.&lt;br /&gt;
&lt;br /&gt;
One reason to force a model to be single threaded would be a bug were to be discovered that impacts your model with multithreaded evaluation. Another would be if you were to discover that multithreaded evaluation was resulting in a net slowdown for your model, or if you were to find that your model is fastest at some particular number of threads.&lt;br /&gt;
&lt;br /&gt;
== Net speed-up gains from multi-threaded evaluation ==&lt;br /&gt;
&lt;br /&gt;
The net speed-up obtained from multi-threaded evaluation depends strongly on the particular model and computations performed. In general, models that manipulate larger arrays are more likely to derive more benefit. &lt;br /&gt;
&lt;br /&gt;
Suppose that 60% of the operations in your model (as measure as a percentage of time in single-threaded evaluation) are able to take advantage of multithreaded evaluation, and these operations experience a 3-fold speedup as a result (as might be realistic with 4 cores after overhead). Then &amp;lt;code&amp;gt;60% * 2/3 = 40%&amp;lt;/code&amp;gt; of the total evaluation time will be saved, which results in a 66% speed-up.  So even with four cores, and fairly favorable conditions, the net speed-up is less than a factor of 2.  &lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
[[Analytica 5.0]] was the first release to include multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[What's new in Analytica 5.0?]]&lt;br /&gt;
* [[Evaluate]]&lt;br /&gt;
* [[GetProcessInfo]]&lt;br /&gt;
* [[Memory usage and management]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48569</id>
		<title>Multithreaded evaluation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48569"/>
		<updated>2016-08-24T14:38:35Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Concepts]]&lt;br /&gt;
''new to [[Analytica 5.0]]''&lt;br /&gt;
&lt;br /&gt;
''Requires [[Analytica Professional]]''&lt;br /&gt;
&lt;br /&gt;
Some computations can take advantage of multiple cores on your computer to speed up to net computation time. These computations partition the task across multiple threads, where each thread can be assigned to a different core. For example, when adding two large arrays, &amp;lt;code&amp;gt;A+B&amp;lt;/code&amp;gt;, where each array has 100,000 elements, the computation might be parallelized across four threads, with each thread handling roughly 25,000 additions each. As a result, the elapsed time to complete the full array addition might be as much as four times faster than it would have been when evaluated in single threaded mode.  Because there is additional overhead required to partition a task and coordinate multiple threads, the actual speedup will end up being something less that the total number of threads.&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation uses fine-grained parallelism, meaning that certain low-level computations are parallelized. The computation is decomposed at a high-level. So when concurrent evaluation is occurring, all threads are working on the same task.&lt;br /&gt;
&lt;br /&gt;
Not all operations are decomposed into parallel computation. In general, arithmetic operations are performed concurrently, but only when the arrays are large enough to justify the extra overhead of multithreading. As a rough idea, operators involving arrays  with fewer than 100 elements will be evaluated on a single thread, operations involving more than 1,000 cells are likely to be performed on multiple threads (if threads are available), and between there the threshold depends on the internal array structure, specific operation, etc.  Several built-in functions operate in parallel, as well as some internal bookkeeping, but again, these use multiple threads only when the arrays involved are large enough to justify the overhead. With new releases of Analytica, additional functions or operations may be enhanced to leverage multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation requires [[Analytica Professional]] or better.  It is not available in [[Analytica Free 101]]. &lt;br /&gt;
&lt;br /&gt;
By default, multithreaded evaluation is disabled in 32-bit Analytica, and it is recommended that you use single threaded evaluation in 32-bit Analytica, since the extra threads consume memory, and is 32-bit Analytica the extra memory space saved by using single-threaded evaluation is usually more important than the speed-ups from multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The configuration of multithreaded evaluation is controlled by two system variables. To change these, navigate the menus to [[Definition menu|Definition]] &amp;gt; System variables &amp;gt; Settings'''.  &lt;br /&gt;
&lt;br /&gt;
=== Max Evaluation Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation, or to a number greater than 1, up to the number of available cores on your computer, to allow multithreaded evaluation. Evaluation will limit the number of threads actually used to this number.&lt;br /&gt;
&lt;br /&gt;
This setting is specific to your computer, and not associated with any model. It persists when you quit and restart Analytica.&lt;br /&gt;
&lt;br /&gt;
If you want to prevent computations from periodically usurping all available cycles, you may opt to set this to a number less than the total number of cores on your computer.  If you are running multiple instances of Analytica or ADE, each may use up to this number of threads. Also, since each thread used does require extra memory, you might want to limit the maximum number of threads when you have a small amount of RAM on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Max Model Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation for the current model, or to 0 to eliminate any maximum number of threads. You can set it to a number greater than 1 to enforce a maximum number of threads that will be used for evaluation by the current model. The number of threads actually used for evaluation will never exceed this number.&lt;br /&gt;
&lt;br /&gt;
This setting is stored with the current model, and so will be set when you share your model with other people, but it won't impact other models.  &lt;br /&gt;
&lt;br /&gt;
Use this setting when you need to limit the number of threads used only for the current model. When Max Model Threads is set, the actual maximum number of threads used will be the smaller of Max Model Threads and Max Evaluation Threads.&lt;br /&gt;
&lt;br /&gt;
One reason to force a model to be single threaded would be a bug were to be discovered that impacts your model with multithreaded evaluation. Another would be if you were to discover that multithreaded evaluation was resulting in a net slowdown for your model, or if you were to find that your model is fastest at some particular number of threads.&lt;br /&gt;
&lt;br /&gt;
== Net speed-up gains from multi-threaded evaluation ==&lt;br /&gt;
&lt;br /&gt;
The net speed-up obtained from multi-threaded evaluation depends strongly on the particular model and computations performed. In general, models that manipulate larger arrays are more likely to derive more benefit. &lt;br /&gt;
&lt;br /&gt;
Suppose that 60% of the operations in your model (as measure as a percentage of time in single-threaded evaluation) are able to take advantage of multithreaded evaluation, and these operations experience a 3-fold speedup as a result (as might be realistic with 4 cores after overhead). Then &amp;lt;code&amp;gt;60% * 2/3 = 40%&amp;lt;/code&amp;gt; of the total evaluation time will be saved, which results in a 66% speed-up.  So even with four cores, and fairly favorable conditions, the net speed-up is less than a factor of 2.  &lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
[[Analytica 5.0]] was the first release to include multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[What's new in Analytica 5.0?]]&lt;br /&gt;
* [[Evaluate]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48568</id>
		<title>Multithreaded evaluation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48568"/>
		<updated>2016-08-24T14:33:25Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Concepts]]&lt;br /&gt;
''new to [[Analytica 5.0]]''&lt;br /&gt;
&lt;br /&gt;
''Requires [[Analytica Professional]]''&lt;br /&gt;
&lt;br /&gt;
Some computations can take advantage of multiple cores on your computer to speed up to net computation time. These computations partition the task across multiple threads, where each thread can be assigned to a different core. For example, when adding two large arrays, &amp;lt;code&amp;gt;A+B&amp;lt;/code&amp;gt;, where each array has 100,000 elements, the computation might be parallelized across four threads, with each thread handling roughly 25,000 additions each. As a result, the elapsed time to complete the full array addition might be as much as four times faster than it would have been when evaluated in single threaded mode.  Because there is additional overhead required to partition a task and coordinate multiple threads, the actual speedup will end up being something less that the total number of threads.&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation uses fine-grained parallelism, meaning that certain low-level computations are parallelized. The computation is decomposed at a high-level. So when concurrent evaluation is occurring, all threads are working on the same task.&lt;br /&gt;
&lt;br /&gt;
Not all operations are decomposed into parallel computation. In general, arithmetic operations are performed concurrently, but only when the arrays are large enough to justify the extra overhead of multithreading. As a rough idea, operators involving arrays  with fewer than 100 elements will be evaluated on a single thread, operations involving more than 1,000 cells are likely to be performed on multiple threads (if threads are available), and between there the threshold depends on the internal array structure, specific operation, etc.  Several built-in functions operate in parallel, as well as some internal bookkeeping, but again, these use multiple threads only when the arrays involved are large enough to justify the overhead. With new releases of Analytica, additional functions or operations may be enhanced to leverage multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation requires [[Analytica Professional]] or better.  It is not available in [[Analytica Free 101]]. &lt;br /&gt;
&lt;br /&gt;
By default, multithreaded evaluation is disabled in 32-bit Analytica, and it is recommended that you use single threaded evaluation in 32-bit Analytica, since the extra threads consume memory, and is 32-bit Analytica the extra memory space saved by using single-threaded evaluation is usually more important than the speed-ups from multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The configuration of multithreaded evaluation is controlled by two system variables. To change these, navigate the menus to [[Definition menu|Definition]] &amp;gt; System variables &amp;gt; Settings'''.  &lt;br /&gt;
&lt;br /&gt;
=== Max Evaluation Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation, or to a number greater than 1, up to the number of available cores on your computer, to allow multithreaded evaluation. Evaluation will limit the number of threads actually used to this number.&lt;br /&gt;
&lt;br /&gt;
This setting is specific to your computer, and not associated with any model. It persists when you quit and restart Analytica.&lt;br /&gt;
&lt;br /&gt;
If you want to prevent computations from periodically usurping all available cycles, you may opt to set this to a number less than the total number of cores on your computer.  If you are running multiple instances of Analytica or ADE, each may use up to this number of threads. Also, since each thread used does require extra memory, you might want to limit the maximum number of threads when you have a small amount of RAM on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Max Model Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation for the current model, or to 0 to eliminate any maximum number of threads. You can set it to a number greater than 1 to enforce a maximum number of threads that will be used for evaluation by the current model. The number of threads actually used for evaluation will never exceed this number.&lt;br /&gt;
&lt;br /&gt;
This setting is stored with the current model, and so will be set when you share your model with other people, but it won't impact other models.  &lt;br /&gt;
&lt;br /&gt;
Use this setting when you need to limit the number of threads used only for the current model. When Max Model Threads is set, the actual maximum number of threads used will be the smaller of Max Model Threads and Max Evaluation Threads.&lt;br /&gt;
&lt;br /&gt;
One reason to force a model to be single threaded would be a bug were to be discovered that impacts your model with multithreaded evaluation. Another would be if you were to discover that multithreaded evaluation was resulting in a net slowdown for your model, or if you were to find that your model is fastest at some particular number of threads.&lt;br /&gt;
&lt;br /&gt;
== Net speed-up gains from multi-threaded evaluation ==&lt;br /&gt;
&lt;br /&gt;
The net speed-up obtained from multi-threaded evaluation depends strongly on the particular model and computations performed. In general, models that manipulate larger arrays are more likely to derive more benefit. &lt;br /&gt;
&lt;br /&gt;
Suppose that 60% of the operations in your model (as measure as a percentage of time in single-threaded evaluation) are able to take advantage of multithreaded evaluation, and these operations experience a 3-fold speedup as a result (as might be realistic with 4 cores after overhead). Then &amp;lt;code&amp;gt;60% * 2/3 = 40%&amp;lt;/code&amp;gt; of the total evaluation time will be saved, which results in a 66% speed-up.  So even with four cores, and fairly favorable conditions, the net speed-up is less than a factor of 2.  &lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
[[Analytica 5.0]] was the first release to include multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[What's new in Analytica 5.0?]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48567</id>
		<title>Multithreaded evaluation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48567"/>
		<updated>2016-08-24T14:31:49Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Concepts]]&lt;br /&gt;
''new to [[Analytica 5.0]]''&lt;br /&gt;
&lt;br /&gt;
''Requires [[Analytica Professional]]''&lt;br /&gt;
&lt;br /&gt;
Some computations can take advantage of multiple cores on your computer to speed up to net computation time. These computations partition the task across multiple threads, where each thread can be assigned to a different core. For example, when adding two large arrays, &amp;lt;code&amp;gt;A+B&amp;lt;/code&amp;gt;, where each array has 100,000 elements, the computation might be parallelized across four threads, with each thread handling roughly 25,000 additions each. As a result, the elapsed time to complete the full array addition might be as much as four times faster than it would have been when evaluated in single threaded mode.  Because there is additional overhead required to partition a task and coordinate multiple threads, the actual speedup will end up being something less that the total number of threads.&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation uses fine-grained parallelism, meaning that certain low-level computations are parallelized. The computation is decomposed at a high-level. So when concurrent evaluation is occurring, all threads are working on the same task.&lt;br /&gt;
&lt;br /&gt;
Not all operations are decomposed into parallel computation. In general, arithmetic operations are performed concurrently, but only when the arrays are large enough to justify the extra overhead of multithreading. As a rough idea, operators involving arrays  with fewer than 100 elements will be evaluated on a single thread, operations involving more than 1,000 cells are likely to be performed on multiple threads (if threads are available), and between there the threshold depends on the internal array structure, specific operation, etc.  Several built-in functions operate in parallel, as well as some internal bookkeeping, but again, these use multiple threads only when the arrays involved are large enough to justify the overhead. With new releases of Analytica, additional functions or operations may be enhanced to leverage multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation requires [[Analytica Professional]] or better.  It is not available in [[Analytica Free 101]]. &lt;br /&gt;
&lt;br /&gt;
By default, multithreaded evaluation is disabled in 32-bit Analytica, and it is recommended that you use single threaded evaluation in 32-bit Analytica, since the extra threads consume memory, and is 32-bit Analytica the extra memory space saved by using single-threaded evaluation is usually more important than the speed-ups from multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The configuration of multithreaded evaluation is controlled by two system variables. To change these, navigate the menus to [[Defiinition menu|Definition]] &amp;gt; System variables &amp;gt; Settings'''.  &lt;br /&gt;
&lt;br /&gt;
=== Max Evaluation Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation, or to a number greater than 1, up to the number of available cores on your computer, to allow multithreaded evaluation. Evaluation will limit the number of threads actually used to this number.&lt;br /&gt;
&lt;br /&gt;
This setting is specific to your computer, and not associated with any model. It persists when you quit and restart Analytica.&lt;br /&gt;
&lt;br /&gt;
If you want to prevent computations from periodically usurping all available cycles, you may opt to set this to a number less than the total number of cores on your computer.  If you are running multiple instances of Analytica or ADE, each may use up to this number of threads. Also, since each thread used does require extra memory, you might want to limit the maximum number of threads when you have a small amount of RAM on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Max Model Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation for the current model, or to 0 to eliminate any maximum number of threads. You can set it to a number greater than 1 to enforce a maximum number of threads that will be used for evaluation by the current model. The number of threads actually used for evaluation will never exceed this number.&lt;br /&gt;
&lt;br /&gt;
This setting is stored with the current model, and so will be set when you share your model with other people, but it won't impact other models.  &lt;br /&gt;
&lt;br /&gt;
Use this setting when you need to limit the number of threads used only for the current model. When Max Model Threads is set, the actual maximum number of threads used will be the smaller of Max Model Threads and Max Evaluation Threads.&lt;br /&gt;
&lt;br /&gt;
One reason to force a model to be single threaded would be a bug were to be discovered that impacts your model with multithreaded evaluation. Another would be if you were to discover that multithreaded evaluation was resulting in a net slowdown for your model, or if you were to find that your model is fastest at some particular number of threads.&lt;br /&gt;
&lt;br /&gt;
== Net speed-up gains from multi-threaded evaluation ==&lt;br /&gt;
&lt;br /&gt;
The net speed-up obtained from multi-threaded evaluation depends strongly on the particular model and computations performed. In general, models that manipulate larger arrays are more likely to derive more benefit. &lt;br /&gt;
&lt;br /&gt;
Suppose that 60% of the operations in your model (as measure as a percentage of time in single-threaded evaluation) are able to take advantage of multithreaded evaluation, and these operations experience a 3-fold speedup as a result (as might be realistic with 4 cores after overhead). Then &amp;lt;code&amp;gt;60% * 2/3 = 40%&amp;lt;/code&amp;gt; of the total evaluation time will be saved, which results in a 66% speed-up.  So even with four cores, and fairly favorable conditions, the net speed-up is less than a factor of 2.  &lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
[[Analytica 5.0]] was the first release to include multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[What's new in Analytica 5.0?]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48566</id>
		<title>Multithreaded evaluation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multithreaded_evaluation&amp;diff=48566"/>
		<updated>2016-08-24T14:27:07Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Concepts]]&lt;br /&gt;
''new to [[Analytica 5.0]]''&lt;br /&gt;
&lt;br /&gt;
''Requires [[Analytica Professional]]''&lt;br /&gt;
&lt;br /&gt;
Some computations can take advantage of multiple cores on your computer to speed up to net computation time. These computations partition the task across multiple threads, where each thread can be assigned to a different core. For example, when adding two large arrays, &amp;lt;code&amp;gt;A+B&amp;lt;/code&amp;gt;, where each array has 100,000 elements, the computation might be parallelized across four threads, with each thread handling roughly 25,000 additions each. As a result, the elapsed time to complete the full array addition might be as much as four times faster than it would have been when evaluated in single threaded mode.  Because there is additional overhead required to partition a task and coordinate multiple threads, the actual speedup will end up being something less that the total number of threads.&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation uses fine-grained parallelism, meaning that certain low-level computations are parallelized. The computation is decomposed at a high-level. So when concurrent evaluation is occurring, all threads are working on the same task.&lt;br /&gt;
&lt;br /&gt;
Not all operations are decomposed into parallel computation. In general, arithmetic operations are performed concurrently, but only when the arrays are large enough to justify the extra overhead of multithreading. As a rough idea, operators involving arrays  with fewer than 100 elements will be evaluated on a single thread, operations involving more than 1,000 cells are likely to be performed on multiple threads (if threads are available), and between there the threshold depends on the internal array structure, specific operation, etc.  Several built-in functions operate in parallel, as well as some internal bookkeeping, but again, these use multiple threads only when the arrays involved are large enough to justify the overhead. With new releases of Analytica, additional functions or operations may be enhanced to leverage multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Multithreaded evaluation requires [[Analytica Professional]] or better.  It is not available in [[Analytica Free 101]]. &lt;br /&gt;
&lt;br /&gt;
By default, multithreaded evaluation is disabled in 32-bit Analytica, and it is recommended that you use single threaded evaluation in 32-bit Analytica, since the extra threads consume memory, and is 32-bit Analytica the extra memory space saved by using single-threaded evaluation is usually more important than the speed-ups from multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The configuration of multithreaded evaluation is controlled by two system variables. To change these, navigate the menus to '''Definition / System variables / Settings'''.  &lt;br /&gt;
&lt;br /&gt;
=== Max Evaluation Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation, or to a number greater than 1, up to the number of available cores on your computer, to allow multithreaded evaluation. Evaluation will limit the number of threads actually used to this number.&lt;br /&gt;
&lt;br /&gt;
This setting is specific to your computer, and not associated with any model. It persists when you quit and restart Analytica.&lt;br /&gt;
&lt;br /&gt;
If you want to prevent computations from periodically usurping all available cycles, you may opt to set this to a number less than the total number of cores on your computer.  If you are running multiple instances of Analytica or ADE, each may use up to this number of threads. Also, since each thread used does require extra memory, you might want to limit the maximum number of threads when you have a small amount of RAM on your computer.&lt;br /&gt;
&lt;br /&gt;
=== Max Model Threads ===&lt;br /&gt;
&lt;br /&gt;
Set this to 1 to force single threaded evaluation for the current model, or to 0 to eliminate any maximum number of threads. You can set it to a number greater than 1 to enforce a maximum number of threads that will be used for evaluation by the current model. The number of threads actually used for evaluation will never exceed this number.&lt;br /&gt;
&lt;br /&gt;
This setting is stored with the current model, and so will be set when you share your model with other people, but it won't impact other models.  &lt;br /&gt;
&lt;br /&gt;
Use this setting when you need to limit the number of threads used only for the current model. When Max Model Threads is set, the actual maximum number of threads used will be the smaller of Max Model Threads and Max Evaluation Threads.&lt;br /&gt;
&lt;br /&gt;
One reason to force a model to be single threaded would be a bug were to be discovered that impacts your model with multithreaded evaluation. Another would be if you were to discover that multithreaded evaluation was resulting in a net slowdown for your model, or if you were to find that your model is fastest at some particular number of threads.&lt;br /&gt;
&lt;br /&gt;
== Net speed-up gains from multi-threaded evaluation ==&lt;br /&gt;
&lt;br /&gt;
The net speed-up obtained from multi-threaded evaluation depends strongly on the particular model and computations performed. In general, models that manipulate larger arrays are more likely to derive more benefit. &lt;br /&gt;
&lt;br /&gt;
Suppose that 60% of the operations in your model (as measure as a percentage of time in single-threaded evaluation) are able to take advantage of multithreaded evaluation, and these operations experience a 3-fold speedup as a result (as might be realistic with 4 cores after overhead). Then &amp;lt;code&amp;gt;60% * 2/3 = 40%&amp;lt;/code&amp;gt; of the total evaluation time will be saved, which results in a 66% speed-up.  So even with four cores, and fairly favorable conditions, the net speed-up is less than a factor of 2.  &lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
[[Analytica 5.0]] was the first release to include multithreaded evaluation.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[What's new in Analytica 5.0?]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Weighted_average&amp;diff=48550</id>
		<title>Weighted average</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Weighted_average&amp;diff=48550"/>
		<updated>2016-08-23T17:35:37Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Mean&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Mean]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Remove_duplicates_in_an_array&amp;diff=48548</id>
		<title>Remove duplicates in an array</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Remove_duplicates_in_an_array&amp;diff=48548"/>
		<updated>2016-08-23T15:35:22Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Unique&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Unique]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Atom&amp;diff=48547</id>
		<title>Atom</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Atom&amp;diff=48547"/>
		<updated>2016-08-23T15:23:59Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Created page with &amp;quot;Category: Objects  An atom or an '''atomic value''' denotes a single element -- a number, text string, a handle, a reference, or the value Null, i....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Objects]]&lt;br /&gt;
&lt;br /&gt;
An [[atom]] or an '''atomic value''' denotes a single element -- a [[number]], [[text]] string, a [[handle]], a [[reference]], or the value [[Null]], i.e. not an [[array]] (table).&lt;br /&gt;
&lt;br /&gt;
Atomic values form the cells of arrays but they may also stand by themselves as values, e.g. the result of evaluating ''1+2'' is the atomic value ''3'', which is not an array. The Title [[attribute]] of any object is an atomic text value. &lt;br /&gt;
&lt;br /&gt;
Because an [[atom]] can be seen as a zero-dimensional array, atoms are functionally equivalent to arrays with zero indexes, enabling the conversion of atoms to arrays in some cases. Nevertheless, in standard usage  the term '''atom''' or '''atomic value''' is used to distinguish simple values from &amp;quot;complex&amp;quot; ones like arrays or lists (one-dimensional arrays).&lt;br /&gt;
&lt;br /&gt;
Because [[atom]]s are not indexed, [[Array Abstraction|array abstraction]] is not always possible on atomic values without a special treatment, see  [[Ensuring_Array_Abstraction#Atom_parameters_and_array_abstraction|Atom parameters and array abstraction]] for details.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Objects and Values]]&lt;br /&gt;
* [[Atomic..Do]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Atom|Atomic function parameters]]&lt;br /&gt;
* [[Ensuring_Array_Abstraction#Atom_parameters_and_array_abstraction|Atom parameters and array abstraction]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Objects_and_Values&amp;diff=48546</id>
		<title>Objects and Values</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Objects_and_Values&amp;diff=48546"/>
		<updated>2016-08-23T15:22:09Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Objects]]&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
There are two primary types of entities that comprise and are manipulated by Analytica models: ''Objects'' and ''Values''. Understanding this simple distinction can help you understand several of the other language features and concepts in Analytica. &lt;br /&gt;
&lt;br /&gt;
An Analytica ''value'' is essentially data. A value can be an ''intelligent array'' or an ''atomic value''. An [[Intelligent Arrays|intelligent array]] is a collection of [[atomic]] values. The result of any calculation is a value. Anything passed as a parameter to a function or an operator is a value. Values can be stored in various ways, and are the entities manipulated through calculation.&lt;br /&gt;
&lt;br /&gt;
An Analytica ''object'' is an entity that has a class, a name, and set of attribute values. Each attribute value associates a value with a particular attribute, so that an object typically contains several values. For example, a (global) variable, which you often see as a rounded rectangle on an influence diagram, is an object that usually has values associated with the attributes [[Title]], [[Description]], [[Units]], [[Definition]], (mid-)[[Value]], [[ProbValue]] (aka. [[Sample]] value), [[Domain]] and [[Check]] among others. In addition, [[Class]] and [[Identifier]] are also attributes.&lt;br /&gt;
&lt;br /&gt;
The word ''entity'' is not a term we use when referring to Analytica concepts. I use it here to help with the description. The terms ''value'' and ''object'' are specific terms we use within Analytica, and each have each have a precise meaning as described in this article. Both of these words are used in other ways in English and in computer science, so take note that we are using these here to refer to ''Analytica values'' and ''Analytica objects'', as opposed to other common meanings of each of those words.&lt;br /&gt;
&lt;br /&gt;
== Values ==&lt;br /&gt;
Value can take subdivided into these subtypes (among others)&lt;br /&gt;
* [[Atomic]] values&lt;br /&gt;
** Numbers&lt;br /&gt;
** Text&lt;br /&gt;
** The [[Null]] value&lt;br /&gt;
** [[Handle]]s&lt;br /&gt;
** [[Reference]]s&lt;br /&gt;
* [[Array]]s&lt;br /&gt;
** Lists&lt;br /&gt;
&lt;br /&gt;
Atomic values form the cells of arrays, but they may also stand by themselves as values. For example, the result of ''1+2'' is the atomic value 3, which is not an array. The Title attribute of any object is an atomic text value. We use the term &amp;quot;atomic value&amp;quot;, or just &amp;quot;atom&amp;quot;, to distinguish from an array.&lt;br /&gt;
&lt;br /&gt;
A array is a rectangular (or hyper-rectangular) collection of &amp;quot;cells&amp;quot;, where each cell contains an atomic value. Arrays can have between 1 and 24 dimensions (or between 1 and 15 dimensions in 32-bit Analytica). Each dimension is associated with an index, with each dimension associated with a different ''index''. An index, by the way is an object. There is one exception -- during computation, one dimension of an array can contain an [[Self-Indexed_Arrays|implicit index]]. A list is a 1-D array where the only dimensions is an implicit dimension. Lists are used to define indexes. See also [[Function_parameter_qualifiers#Atom|Atomic function parameters]] and [[Atomic..Do]].&lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
An Analytica object is an entity that has a [[Class]], an [[Identifier]] (or name), and several other attribute values. The class and identifier are in fact attributes themselves.  Most objects are in the global namespace, and each object in the global namespace must have a unique identifier. Some objects, most notably [[Local Indexes|local indexes]], are not in the global namespace, and don't need to have a unique [[identifier]].&lt;br /&gt;
&lt;br /&gt;
Objects can be sub-divided into the following subtypes (among others)&lt;br /&gt;
* Global variables&lt;br /&gt;
** Decision variables&lt;br /&gt;
** General variables&lt;br /&gt;
** [[Chance]] variables&lt;br /&gt;
** [[Objective]] variables&lt;br /&gt;
** [[DefineOptimization#Constraints|Constraint]] variables&lt;br /&gt;
** (Global) indexes&lt;br /&gt;
** Constants&lt;br /&gt;
** [[System variables]]&lt;br /&gt;
* Functions&lt;br /&gt;
** Built-in functions&lt;br /&gt;
** [[User-Defined Functions]]&lt;br /&gt;
* [[Modules_and_Libraries|Modules]]&lt;br /&gt;
** Model objects&lt;br /&gt;
** [[Libraries]]&lt;br /&gt;
* [[Buttons]]&lt;br /&gt;
* Pictures&lt;br /&gt;
* Text nodes&lt;br /&gt;
* [[User input nodes and user output nodes|FormNodes]] (user input and output nodes)&lt;br /&gt;
* [[Alias nodes]]&lt;br /&gt;
* [[Graph Style Templates|Graph style templates]]&lt;br /&gt;
* [[Local Indexes]]&lt;br /&gt;
* [[Domain Indexes]]&lt;br /&gt;
* [[Attributes]]&lt;br /&gt;
&lt;br /&gt;
The [[Object Window]] is used to view an object, and from that window you can directly see the various attribute values contained within the object. The [[Object Window]] shows you a subset of these values. From the [[Typescript Window]], you can use the [[Profile]] command so see all the attribute values in an object.&lt;br /&gt;
&lt;br /&gt;
== What about COM Objects? ==&lt;br /&gt;
Are [[COM Integration|COM objects]] actually objects, as the name implies? The answer is that they are not ''Analytica objects'', as identified above, although they do have similar characteristics in many ways. For example, whereas Analytica objects have attribute values, COM objects have properties. As mentioned earlier, the word ''object'' is used in many ways in computer science, and the term ''COM objects'' was created outside the context of Analytica. When you call [[COMCreateObject]], a thing called a ''COM object'' is instantiated somewhere in your computer's memory (it can even be in the memory of a remote computer), but the result from [[COMCreateObject]] is a &amp;quot;''moniker''&amp;quot; or &amp;quot;''pointer''&amp;quot; to that object, which is a type of atomic value that is used to reference that thing. This pointer is an Analytica value.&lt;br /&gt;
&lt;br /&gt;
Suppose you define a variable, &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, to be a call to [[COMCreateObject]]. Its result is a pointer to that COM object. If you then define variable &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;, the pointer is copied, but there is still only a single COM object. Now both &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt; point to the same COM object.&lt;br /&gt;
&lt;br /&gt;
== Indirect Referents ==&lt;br /&gt;
A [[Handle]] is an indirect referent to an Analytica object, and a [[Reference]] is an indirect referent to an Analytica value. These are the two fundamental forms of indirection referents. You can think of an ''indirect referent'' as a ''pointer''.  For example, an object exists somewhere in memory. There is only one copy of this object. But you might want to refer to this object -- that is the role of a [[handle]].  Similarly, a value exists somewhere in memory. You may want to refer to that value without making a copy of it -- a [[Reference]] allows you to do this. When you create multiple copies of a [[handle]], the object itself is not copies -- they all point to the same object -- you end up with several handles to the same object.&lt;br /&gt;
&lt;br /&gt;
Because Analytica is a functional language with [http://en.wikipedia.org/wiki/Referential_transparency_(computer_science) referential transparency], a reference does not allow you to change the contents of a value. Any time you make a change to a value, a new copy must be made. However, the useful thing about a [[reference]] is that it is itself an atomic value. So even though it might &amp;quot;point&amp;quot; to an array, it acts as an atom for [[Array Abstraction]].&lt;br /&gt;
&lt;br /&gt;
== Locals ==&lt;br /&gt;
Locals are identifies in expressions that act as names for either values or objects. There are a couple different types of locals:&lt;br /&gt;
&lt;br /&gt;
* [[Local Indexes]]&lt;br /&gt;
* [[LocalAlias]]&lt;br /&gt;
* [[MetaVar]]s and standard local variables&lt;br /&gt;
&lt;br /&gt;
Local indexes create an index object, which can then serve as the dimension on an array. The identifier of the local index is therefore a name that can be used to refer to the index object. Local indexes to not live in the global namespace, so they do not need to have a unique identifier. When you declare a local index, you can specify the object name explicitly, and it does not have to be the same as the local name. This is done using this syntax&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Index I / &amp;quot;''Name''&amp;quot; := expr;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Within the lexical scope of &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;, you can refer to this index object by &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;, but the name of the object is actually &amp;lt;code&amp;gt;Name&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
A [[LocalAlias]] declares a name for an object, that can be used within a local lexical expression scope. Hence, in the following declarations, &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; can be used as names for other pre-existing objects.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;LocalAlias I := Data.Row;&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;LocalAlias J := Handle(Va1);&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;LocalAlias K := Contains of ModelDetailsModule;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the last example, &amp;lt;code&amp;gt;[[Contains]] of ModelDetailsModule&amp;lt;/code&amp;gt; is a list of [[handle]]s, but within the lexical scope of &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; will name only one of these objects at a time. The ''body expression'' -- that expression in the lexical scope of &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;, will be evaluated once for each object in &amp;lt;code&amp;gt;[[Contains]] of ModelDetailsModule&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Most other local variables, declared using [[MetaVar..Do]], [[Var..Do]], or [[For..Do]], are alias to values. It is important to note that ''local variables are not Analytica objects'', whereas global variables (those that show on influence diagrams) are Analytica objects. Again -- ''local variables declare a name for a value''. There is only one value -- there is not a separate [[Value|Mid-Value]] or [[ProbValue|Sample-Value]]. The value is computed and set when the variable is declared (or assigned to), and after that, the [[Evaluation Modes|evaluation mode]] has no relevance.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:2;-moz-column-count:2;-webkit-column-count:2&amp;quot;&amp;gt;&lt;br /&gt;
* [[The domain of possible values]]&lt;br /&gt;
* [[Values in Object Window]]&lt;br /&gt;
* [[Evaluation Modes]]&lt;br /&gt;
* [[Objects_and_Their_Attributes_-_Part_1_of_3|Objects and Their Attributes]]&lt;br /&gt;
* [[Attrib of Obj]]&lt;br /&gt;
* [[Classes of variables and other objects]]&lt;br /&gt;
* [[Change class of an object]]&lt;br /&gt;
* [[Atom]]&lt;br /&gt;
* [[Array]]&lt;br /&gt;
* [[Class]]&lt;br /&gt;
* [[COM Integration|COM objects]] &lt;br /&gt;
* [[Object window]]&lt;br /&gt;
* [[Object menu]]&lt;br /&gt;
* [[Object Manipulation Typescript Commands]]&lt;br /&gt;
* [[LocalAlias]]&lt;br /&gt;
* [[Contains]]&lt;br /&gt;
* [[Identifier]]&lt;br /&gt;
* [[Numbers]]&lt;br /&gt;
* [[Handles to Objects]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Atomic..Do&amp;diff=48545</id>
		<title>Atomic..Do</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Atomic..Do&amp;diff=48545"/>
		<updated>2016-08-23T15:21:17Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Evaluation Functions]]&lt;br /&gt;
&lt;br /&gt;
== Atomic x := expr Do body ==&lt;br /&gt;
Declares a local variable, «x», that can be referred to only from within the expression «body», and assigns it the initial value obtained by evaluating «expr».  When used from within «body», Analytica guarantees that the value of «x» is [[Objects_and_Values#Values|atomic]] -- i.e., non-[[array]]-valued. Analytica achieves this guarantee by iterating (horizontally [[Array Abstraction|array abstracting]]) across the result of «expr» when it is array-valued.&lt;br /&gt;
&lt;br /&gt;
'''Atomic''' «x» := «expr» '''Do''' «body» is exactly equivalent to:&lt;br /&gt;
:[[MetaVar]] «x»[ ] := «expr» Do «body»&lt;br /&gt;
&lt;br /&gt;
In most common scenarios, it is also equivalent to these, although there are some subtle distinctions as special cases.&lt;br /&gt;
:[[For]] «x» := «expr» Do «body»&lt;br /&gt;
:[[For]] «x»[ ] := «expr» Do «body»&lt;br /&gt;
:[[Var]] «x»[ ] := «expr» Do «body»&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
This construct was introduced in Analytica 4.2.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Atom]]&lt;br /&gt;
* [[Objects_and_Values#Values|Atomic values]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Atom|Atomic function parameters]]&lt;br /&gt;
* [[Var..Do]]&lt;br /&gt;
* [[MetaVar..Do]]&lt;br /&gt;
* [[For..Do]]&lt;br /&gt;
* [[For versus Var]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Text&amp;diff=48544</id>
		<title>Text</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Text&amp;diff=48544"/>
		<updated>2016-08-23T15:17:01Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Text values&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Text values]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Number&amp;diff=48543</id>
		<title>Number</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Number&amp;diff=48543"/>
		<updated>2016-08-23T15:16:27Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Numbers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Numbers]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Array_Abstraction&amp;diff=48542</id>
		<title>Array Abstraction</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Array_Abstraction&amp;diff=48542"/>
		<updated>2016-08-23T15:01:19Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Arrays]]&lt;br /&gt;
[[Category:Doc Status D]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(in-progress)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
'''Array abstraction''' is one of the most powerful features in Analytica.  Although conceptually simple, Analytica modelers find that their mastery of [[array]] abstraction continues to improve over the course of years.  Array abstraction provides many benefits:&lt;br /&gt;
* Flexibility: Easy to alter an [[index]], e.g., adding or deleting elements.&lt;br /&gt;
* Hyper-flexibility: Easy to adjust the dimensionality of a model, even late in the modeling process.&lt;br /&gt;
* Direct [[what-if analysis]] and [[parametric analysis]].&lt;br /&gt;
* Simplifies expressions, which increases transparency&lt;br /&gt;
* Reduces the cognitive load of the modeler, with dramatic productivity gains during model creation.&lt;br /&gt;
* Speed - Analytica is an array-based semi-interpreted language, but array operations, the bulk of the computation, occur in &amp;quot;native code&amp;quot;.&lt;br /&gt;
* Representational Power: Any simple scalar function becomes a powerful array function when abstracted.&lt;br /&gt;
* Synergy with probabilistic inference: [[Monte Carlo]] and [[Latin Hypercube]] simulation are accomplished in Analytica through array abstraction.  The [[Run]] index (i.e., the simulation index), is just another dimension, and the [[propagation of uncertainties]] through the model is an instance of array abstraction at work.&lt;br /&gt;
&lt;br /&gt;
== Array abstraction of a scalar function ==&lt;br /&gt;
=== One parameter function ===&lt;br /&gt;
The function [[Sqrt]](x) computes the square root of «x». When you supply an array as a parameter, array abstraction iterates the function over all elements of the array and returns an array with the same dimensionality as the original.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;A := &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_A.png]]&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Sqrt(A) :=&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_B.png]]&lt;br /&gt;
&lt;br /&gt;
[[Sqrt]] is an example of a scalar function with one parameter. We say that it treats its parameter as ''atomic'', or it treats its parameter as an ''atom''.  &lt;br /&gt;
&lt;br /&gt;
=== Parameters have same indexes ===&lt;br /&gt;
The plus operator treats both its parameters as atoms. If both values supplied to the parameters have the same dimensionality, then array abstraction iterates over each index combination, producing an array result with the same dimensionality as the parameters. &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable B := Sqrt(A)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;A + B &amp;amp;rarr;&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_A+B.png]]&lt;br /&gt;
&lt;br /&gt;
=== An array parameter with a scalar parameter ===&lt;br /&gt;
The [[Mod]](x, y) function returns the remainder of dividing «x» by «y». It treats both parameters as atoms. When one parameter is an array and the other is scalar, array abstraction iterates over each cell of the array and applies the function using the same scalar value.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Mod(A, 5) &amp;amp;rarr; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_Mod_A_B.png]]&lt;br /&gt;
&lt;br /&gt;
=== Equivalence of a scalar and a non-varying array ===&lt;br /&gt;
When you combine an array with a scalar, you get the same result as you would get if you combined the array with another array having the same indexes, but where every cell contains the scalar value. &lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_A.png]] &amp;lt;code&amp;gt;+ 5 &amp;amp;rarr;&amp;lt;/code&amp;gt; &lt;br /&gt;
:[[image:ArrayAbstract_A+5.png]]&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_A.png]] &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; [[image:ArrayAbstract_5.png]] &amp;lt;code&amp;gt;&amp;amp;rarr;&amp;lt;/code&amp;gt; &lt;br /&gt;
:[[image:ArrayAbstract_A+5.png]]&lt;br /&gt;
&lt;br /&gt;
We say that an array that does not vary is equivalent to scalar with respect to array abstraction. It is a general principle that exchanging a value with an equivalent value in a computation produces an equivalent result. The indexes of the new result might be different, but if so, the result will be constant along any index that does not appear in its equivalent result.&lt;br /&gt;
&lt;br /&gt;
This principle of equivalence gives rise to a general principle in Analytica modeling: You only need to include an index if the data you are representing varies over that index. &lt;br /&gt;
&lt;br /&gt;
An inverse perspective is that you can conceptualize any value has if it has every index, but does not vary along those indexes that aren't shown.&lt;br /&gt;
&lt;br /&gt;
=== Combining arrays with different indexes ===&lt;br /&gt;
When the two (or more) parameters to a scalar function or operator are arrays with different indexes, the result has the union of the indexes from the parameters. For example, if the first parameter has indexes &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;, and the second parameter has indexes &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;, the result has indexes &amp;lt;code&amp;gt;I, J&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
From the previous subsection, we saw that an array index by &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt; is equivalent to an array indexed by &amp;lt;code&amp;gt;I, J&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; which does not vary along &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;. Similarly, an array indexed by &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; is equivalent to and array indexed by &amp;lt;code&amp;gt;I, J&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; that does not vary along &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;. You can substitute these equivalent arrays for the originals to obtain two arrays with identical dimensionality, which is a case covered above.&lt;br /&gt;
&lt;br /&gt;
Another way to think about it is that for each cell in the result, find the cell in each parameter that matches on the coordinates for the indexes that the result and parameter has in common. Apply the scalar function to those cells to obtain the result.&lt;br /&gt;
&lt;br /&gt;
Consider this example:&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_C.png]] &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; [[image:ArrayAbstract_D.png]] &amp;lt;code&amp;gt;&amp;amp;rarr; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_C+D.png]]&lt;br /&gt;
&lt;br /&gt;
First, observe that the result has all indexes from the parameters. Then, notice that the result cell for &amp;lt;code&amp;gt;[I = 3, J = 2]&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;C[I = 3] + D[J = 2]&amp;lt;/code&amp;gt;. You should study the example to understand where each result cell comes from. You should also study the next example.&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_C.png]] &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt; [[image:ArrayAbstract_D2.png]] &amp;lt;code&amp;gt;&amp;amp;rarr;&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_C+D2.png]]&lt;br /&gt;
&lt;br /&gt;
=== Test yourself ===&lt;br /&gt;
The two indexes named &amp;lt;code&amp;gt;Tens&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Ones&amp;lt;/code&amp;gt; are defined as &amp;lt;code&amp;gt;0..9&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;Pos&amp;lt;/code&amp;gt; has these indexes as shown.&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_Pos.png]]&lt;br /&gt;
&lt;br /&gt;
* Write a short expression for the Definition of &amp;lt;code&amp;gt;Pos&amp;lt;/code&amp;gt; that produces this result. Hint: It requires only two arithmetic operations.&lt;br /&gt;
&lt;br /&gt;
The array &amp;lt;code&amp;gt;N_sqr&amp;lt;/code&amp;gt; has index &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;N := 0..99&amp;lt;/code&amp;gt;, and each cell is equal to the square of &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_N_sqr.png]]&lt;br /&gt;
&lt;br /&gt;
The [[Subscript]] expression, &amp;lt;code&amp;gt;N_sqr[N = Pos]&amp;lt;/code&amp;gt;, can be viewed as a scalar function of &amp;lt;code&amp;gt;Pos&amp;lt;/code&amp;gt;. In function syntax, this can be equivalently written as &amp;lt;code&amp;gt;Subscript(N_sqr, N, Pos)&amp;lt;/code&amp;gt;. Note: The first parameter of [[Subscript]] is not a scalar -- it expects an array, but here you can visualize that as being fixed, so that we are essentially considering the function&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Function F(x) := N_sqrt[N = x]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is a scalar function of &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
* Use the principles of array abstraction on scalar functions to find the result of &amp;lt;code&amp;gt;N_sqrt[N = Pos]&amp;lt;/code&amp;gt;. Note: An array, &amp;lt;code&amp;gt;Pos&amp;lt;/code&amp;gt; is being passed to a parameter that is treated as an atom.&lt;br /&gt;
&lt;br /&gt;
== Array abstraction of a function with an array parameter ==&lt;br /&gt;
The above section considered the case where a function treats a parameter as atomic. Let's now consider the case where a function operates over an array.&lt;br /&gt;
&lt;br /&gt;
=== Functions with one array parameter ===&lt;br /&gt;
The function &amp;lt;code&amp;gt;Sum(x, I)&amp;lt;/code&amp;gt; expects an array for the first parameter. It also expects an index as a second parameter, which tells the function which index to operate over. It is generally the case for a functions that array-abstracts that an array parameter is accompanied by an index (or indexes) specified which indexes are operated over. You can say that [[Sum]] expects the first parameter to be an array indexed by «I». In other words, it expects the first parameter to be a one-dimensional array.&lt;br /&gt;
&lt;br /&gt;
Although &amp;lt;code&amp;gt;Sum(x, I)&amp;lt;/code&amp;gt; expects «x» to be one-dimensional, there is no problem with passing a 2-D, or even 10-D, value to the first parameter. Once again, array abstraction kicks in and iterates over all combinations the indexes of «x» excluding index «I». For each combination, it takes the slice that remains and applies the function.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;A := &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_A.png]]&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Sum(A, I) := &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[image:ArrayAbstract_Sum_A_I.png]]&lt;br /&gt;
&lt;br /&gt;
In the example here, &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; contains and extra index, &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;. So &amp;lt;code&amp;gt;Sum(A, I)&amp;lt;/code&amp;gt; iterates over &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;. It calculates the sum over &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; for the slice &amp;lt;code&amp;gt;A[J = 1]&amp;lt;/code&amp;gt;, and then again for the slice &amp;lt;code&amp;gt;A[J = 2]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Test yourself: Notice that &amp;lt;code&amp;gt;Sum(A, I)[J = 2]&amp;lt;/code&amp;gt; is the same as &amp;lt;code&amp;gt;Sum(A[J = 2], I)&amp;lt;/code&amp;gt;. Is there a general principle here?&lt;br /&gt;
&lt;br /&gt;
== The general principle of array abstraction ==&lt;br /&gt;
== Composition and array abstraction ==&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Intelligent Arrays]]&lt;br /&gt;
* [[Ensuring Array Abstraction]]&lt;br /&gt;
* [[Writing Array-Abstractable Definitions]]&lt;br /&gt;
* [https://www.youtube.com/watch?v=_8ZaXnEwhoE Intelligent Array Abstraction] (an explanatory video on YouTube)&lt;br /&gt;
* [[Expressions that don't array-abstract]]&lt;br /&gt;
* [[Array Manipulation Examples and Challenge Problems]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Unique&amp;diff=48541</id>
		<title>Unique</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Unique&amp;diff=48541"/>
		<updated>2016-08-23T14:57:09Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* Unique(a, I) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Functions that create lists]]&lt;br /&gt;
[[Category:Array Library]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==Unique(a'', &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt;'')== &lt;br /&gt;
&lt;br /&gt;
Without the index parameter &amp;lt;code&amp;gt;«I»&amp;lt;/code&amp;gt;, returns a list containing all the unique [[atom]]s in «a». The resulting list has any duplicates removed. «a» can be a multidimensional array, and the result contains the unique atoms (cells) across all dimensions.&lt;br /&gt;
&lt;br /&gt;
When an index &amp;lt;code&amp;gt;«I»&amp;lt;/code&amp;gt; is specified, it returns a maximal subset of index &amp;lt;code&amp;gt;«I»&amp;lt;/code&amp;gt; such that each indicated [[slice]] of array «a»  along &amp;lt;code&amp;gt;«I»&amp;lt;/code&amp;gt; is unique. This usage can be used to remove duplicate slices from an array, or to identify a single member of each equivalence class.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Let:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable DataSet :=&amp;lt;/code&amp;gt;&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!&lt;br /&gt;
!colspan=&amp;quot;3&amp;quot; | Field &amp;amp;#9654;&lt;br /&gt;
|-&lt;br /&gt;
!PersonNum &amp;amp;#9660;'''&lt;br /&gt;
!LastName&lt;br /&gt;
!FirstName&lt;br /&gt;
!Company&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot; |1&lt;br /&gt;
|Smith&lt;br /&gt;
|Bob&lt;br /&gt;
|Acme&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot; |2&lt;br /&gt;
|Jones&lt;br /&gt;
|John&lt;br /&gt;
|Acme&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot; |3&lt;br /&gt;
|Johnson&lt;br /&gt;
|Bob&lt;br /&gt;
|Floorworks&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot; |4&lt;br /&gt;
|Smith&lt;br /&gt;
|Bob&lt;br /&gt;
|Acme&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Then: &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Unique(DataSet) &amp;amp;rarr; ['Smith', 'Jones', 'Johnson', 'Bob', 'John', 'Acme', 'Floorworks' ]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Unique(DataSet, PersonNum) &amp;amp;rarr; [1, 2, 3]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Unique(DataSet[Field = 'Company'], PersonNum) &amp;amp;rarr; [1, 3]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Optional parameters ==&lt;br /&gt;
=== Position ===&lt;br /&gt;
By default, [[Unique]] returns the elements of the index.  Setting the optional parameter «position»  equal &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;position: true&amp;lt;/code&amp;gt;) will return the positions of the elements in &amp;lt;code&amp;gt;«I»&amp;lt;/code&amp;gt; , rather than the elements themselves (see [[Associative vs. Positional Indexing]]).&lt;br /&gt;
&lt;br /&gt;
This parameter is not used when the &amp;lt;code&amp;gt;«I»&amp;lt;/code&amp;gt; index parameter is omitted.&lt;br /&gt;
&lt;br /&gt;
===CaseInsensitive===&lt;br /&gt;
When applying [[Unique]] to text values, values are considered by default in a case-sensitive fashion,  for example, &amp;quot;Apple&amp;quot; and &amp;quot;apple&amp;quot; are considered distinct elements.  &lt;br /&gt;
&lt;br /&gt;
Specifying &amp;lt;code&amp;gt;caseInsensitive: true&amp;lt;/code&amp;gt; ignores differences in upper and lower case in text values when determining if values are unique.&lt;br /&gt;
&lt;br /&gt;
=== ResultIndex ===&lt;br /&gt;
&lt;br /&gt;
When an index is provided for this parameter, the result is indexed by the given [[index]] instead of being an unindexed list. If the index supplied is shorter than the number of unique items, then only the first ''n'' items are returned, where ''n'' is the size of the index. When the result index is too long, the result is [[null]]-padded.&lt;br /&gt;
&lt;br /&gt;
«ResultIndex» can be useful when you want to [[Array Abstraction|array abstract]]. For example, in a 2-D array &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, you may want to identify the unique items along &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; separately for each item in index &amp;lt;code&amp;gt;J&amp;lt;/code&amp;gt;, as follows.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;For jj := J Do Unique(a[J = jj], I, resultIndex: I)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Without the «resultIndex» parameter, each iteration would return a list, and the [[For]] loop would then need to combine multiple list (i.e., implicit dimensions), which would be disallowed and result in an error. By ensuring that each result has an explicit index -- &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; in this example -- the results can be successfully combined.&lt;br /&gt;
&lt;br /&gt;
It is also worth noting that the [[For]] loop example just given is not equivalent to&lt;br /&gt;
:&amp;lt;code&amp;gt;Unique(a, I, resultIndex: I)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reason is that &amp;lt;code&amp;gt;Unique(a, I)&amp;lt;/code&amp;gt; compares entire [[slice]]s -- it isn't operating over each slice of the exogenous dimensions separately as most other array functions do.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
The [[Set Functions]] such as [[SetDifference]] or [[SetUnion]] ensure that no duplicates exist in the final result, and hence can also be used to find the unique elements. For example, when &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; is a 1-D array or list&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;#SetDifference(\L)&amp;lt;/code&amp;gt;&lt;br /&gt;
and &lt;br /&gt;
:&amp;lt;code&amp;gt;Unique(L)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
do the same thing. Since no set is being differences, [[SetDifference]] returns the set &amp;lt;code&amp;gt;\L&amp;lt;/code&amp;gt; after duplicates are removed.  In some instances, [[SetDifference]] has advantages over [[Unique]]. For example, if you also want to ignore certain values, including [[Null]] or others, you could compute the unique elements and then follow that with a call to [[SetDifference]] to remove the other values, but when so doing, you might as well skip the call to [[Unique]] entirely since [[SetDifference]] already does that for you.&lt;br /&gt;
&lt;br /&gt;
The ordering of elements in the result follows the ordering of the elements in «a», which often feels arbitrary. Hence, it is common to wrap the call to [[Unique]] is a call to [[SortIndex]] such as&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SortIndex(Unique(a))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
The «I» parameter was first made optional in [[Analytica 5.0]]. Prior to that, the &amp;lt;code&amp;gt;Unique(a)&amp;lt;/code&amp;gt; usage was not available. Without to omitted index, use &amp;lt;code&amp;gt;a[I = Unique(a, I)]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;#SetDifference(\a)&amp;lt;/code&amp;gt; to define an index.&lt;br /&gt;
&lt;br /&gt;
The «resultIndex» parameter is present in [[Analytica 4.3]] and later, but hidden (doesn't show up in [[Expression Assist]], etc.) until [[Analytica 5.0]]. You can still use it in those earlier releases even though it is hidden.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[SortIndex]]&lt;br /&gt;
* [[Subset]]&lt;br /&gt;
* [[Set Functions]] -- These also remove duplicates from their results.&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Count&amp;diff=48540</id>
		<title>Count</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Count&amp;diff=48540"/>
		<updated>2016-08-23T14:30:52Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Sum&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Sum]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Count_atom&amp;diff=48539</id>
		<title>Count atom</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Count_atom&amp;diff=48539"/>
		<updated>2016-08-23T14:30:17Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Sum&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Sum]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Numbers&amp;diff=48537</id>
		<title>Numbers</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Numbers&amp;diff=48537"/>
		<updated>2016-08-23T00:03:39Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica User Guide]]&lt;br /&gt;
[[Category: Number formats]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressions &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can enter a number into an expression using any available number formats in (see [[Number formats]]), including:&lt;br /&gt;
:&amp;lt;code&amp;gt;2008, 12.345, 0.00123, 5.3E20, 5.3E-20, $100,000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suffix format uses a letter or symbol suffix to denote a power of ten, such as:&lt;br /&gt;
:&amp;lt;code&amp;gt;25K, 200M, 123p, 20%&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suffix format provides a simple, familiar way to specify large or small numbers. See [[Number formats|Suffix characters]] for details.&lt;br /&gt;
&lt;br /&gt;
You can usually enter numbers using most number format types directly into an expression no matter what number format was specified for the variable defined by the expression. The exceptions are:&lt;br /&gt;
&lt;br /&gt;
# You may use commas to separate groups of three digits, such as &amp;lt;code&amp;gt;123,456.00&amp;lt;/code&amp;gt;, only if the expression consists of that single number. If the number is part of an expression with other elements, such as &amp;lt;code&amp;gt;12*123,456&amp;lt;/code&amp;gt;, you may ''not ''use comma separators because the syntax would be ambiguous. You should use simply &amp;lt;code&amp;gt;12*123456&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Dates, date-times, or times-of-day must be typed in a very specific format when the number format is not set to date, or when they appear within an expression with other elements. See [[Date and Time Values]].&lt;br /&gt;
&lt;br /&gt;
'''Integers, Fixed Point and Floating Point''': Integer values that you enter between &amp;lt;code&amp;gt;-9,223,372,036,854,775,807&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;9,223,372,036,854,775,807&amp;lt;/code&amp;gt; are represented internally as integers, and numbers that you enter between &amp;lt;code&amp;gt;-9,223,372,036,854.775807&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;9,223,372,036,854.775807&amp;lt;/code&amp;gt; with 6 or fewer decimals are represented internally with full precision as fixed-point numbers. Numbers with more than 6 decimal digits of precision or outside these ranges are represented using 64-bit binary floating point numbers.&lt;br /&gt;
&lt;br /&gt;
'''Precision''': Integer and fixed-point numbers are exact representations of the numeric value, and hence, Analytica prefers these representations when possible. Floating point values are, in general, approximate values, accurate to about 15 significant digits. Many base-10 floating point numbers cannot be represented exactly in binary, and hence may have some rounding error in the 16th digit.&lt;br /&gt;
&lt;br /&gt;
'''Round-off error''': Some calculations, especially those that involve small differences between large numbers or large numbers of additions, might result in less precision than this maximum, or may magnify existing [[round]]-off error.&lt;br /&gt;
&lt;br /&gt;
When calculations are performed with integer or fixed-point numbers, the result is represented internally as an integer or fixed-point number if Analytica is able to do so, which it usually is able to do with addition, subtraction, and multiplication. These results have zero round-off error. With many other operations, such as division or functions like [[Sqrt]](), this is not possible, so the result is floating point number. Operations involving floating-point numbers result in floating-point numbers even if the result appears to be an integer, since the result is no longer guaranteed exact, and always subject to the possibility that round-off error could accumulate.&lt;br /&gt;
&lt;br /&gt;
'''Largest and smallest numbers''': Analytica can represent positive numbers between about 10&amp;lt;sup&amp;gt;-320&amp;lt;/sup&amp;gt; and 1.797x10&amp;lt;sup&amp;gt;308&amp;lt;/sup&amp;gt;. If a calculation would result in a number smaller than about 10&amp;lt;sup&amp;gt;-320&amp;lt;/sup&amp;gt;, it rounds it down zero:&lt;br /&gt;
:&amp;lt;code&amp;gt;1/10^1000 &amp;amp;rarr; 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the result would be larger than 1.797x10&amp;lt;sup&amp;gt;308&amp;lt;/sup&amp;gt; it returns &amp;lt;code&amp;gt;INF&amp;lt;/code&amp;gt; (infinity):&lt;br /&gt;
:&amp;lt;code&amp;gt;10^1000 &amp;amp;rarr; INF&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more, see [[Exception values INF, NAN, and NULL]].&lt;br /&gt;
&lt;br /&gt;
'''Complex Numbers''': To enter the imaginary part of a [[Complex Numbers|complex number]], append a lowercase ''j ''or ''i ''to the number, as in these examples&lt;br /&gt;
:&amp;lt;code&amp;gt;1j, -1-1j, -2M+23Kj, 4-7e-8j&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;4-7e-8j&amp;lt;/code&amp;gt; example, the imaginary part is &amp;lt;code&amp;gt;-7e-8&amp;lt;/code&amp;gt; (i.e., &amp;lt;code&amp;gt;-70n&amp;lt;/code&amp;gt;). There cannot be a space between the digit and the ''j'', and if you want just the imaginary number, you must write &amp;lt;code&amp;gt;1i&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;1j&amp;lt;/code&amp;gt;, since without the preceding 1, you would be referring to a variable named &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;j&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The real and imaginary components are both represented internally as 32-bit floating point numbers, each spanning the range from &amp;lt;code&amp;gt;3.4e+38&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;3.4e-38&amp;lt;/code&amp;gt; with about 7 digits of precision. A complex number consumes the same amount of memory as a real number, but sacrifices range and precision to do so. As a result, you will experience greater round-off error in calculations that use complex numbers.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:2;-moz-column-count:2;-webkit-column-count:2&amp;quot;&amp;gt;&lt;br /&gt;
* [[Number formats]]&lt;br /&gt;
* [[Number Format Dialog]]&lt;br /&gt;
* [[NumberFormat]] attribute&lt;br /&gt;
* [[Data_Type_Functions#Function_IsNumber|IsNumber]]&lt;br /&gt;
* [[NaN|Not a Number]]&lt;br /&gt;
* [[INF, NAN, and Null]]&lt;br /&gt;
* [[INF, NAN, and NULL - Exception values]]&lt;br /&gt;
* [[IsNaN]]&lt;br /&gt;
* [[IsNull]]&lt;br /&gt;
* [[Complex Numbers]]&lt;br /&gt;
* [[EnableComplexNumbers]]&lt;br /&gt;
* [[Complex number functions]]&lt;br /&gt;
* [[Binary and hexadecimal integer formats]]&lt;br /&gt;
* [[ReadBinaryFile]]&lt;br /&gt;
* [[WriteBinaryFile]]&lt;br /&gt;
* [[BitAnd]]&lt;br /&gt;
* [[Numbers and text]]&lt;br /&gt;
* [[Converting Numbers to Text]]&lt;br /&gt;
* [[NumberToText]]&lt;br /&gt;
* [[ParseNumber]]&lt;br /&gt;
* [[Round]]&lt;br /&gt;
* [[Numeric Tolerance and Precision]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Number| Number type function parameters]] &lt;br /&gt;
* [[The_Analytica_Domain_Attribute#Discrete_Numeric|Numeric variables]]&lt;br /&gt;
* [[Domain_Expressions#Integer.28.29|Integer() variable specification function]]&lt;br /&gt;
* [[Math functions]]&lt;br /&gt;
* [[Objects and Values]]&lt;br /&gt;
* [[Multiple formats in one table]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Expressions / {{PAGENAME}} / Date and Time Values&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Text_values&amp;diff=48536</id>
		<title>Text values</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Text_values&amp;diff=48536"/>
		<updated>2016-08-23T00:02:53Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressions &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You specify a text value by enclosing text between single quotes, or between double quotes, for example:&lt;br /&gt;
:&amp;lt;code&amp;gt;'A', &amp;quot;A25&amp;quot;, 'A longish text - with punctuation.'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A text value can contain any character, including any digit, comma, space, and new line. To include a single quote(&amp;lt;code&amp;gt;'&amp;lt;/code&amp;gt;) or apostrophe, type two single quotes in sequence, such as:&lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;'Isn''t this easy?'&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting text contains only one apostrophe. Or you can enclose the text value in double quotes:&lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;quot;Don't do that!&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, if you want to include double quotes, enclose the text in single quotes:&lt;br /&gt;
:&amp;lt;code&amp;gt;'Did you say &amp;quot;Yes&amp;quot;?'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can enter a text value directly as the value of a variable, or in an expression, including as an element of a list (see [[Creating an index]]) or edit table (see [[Defining a variable as an edit table]]). Analytica displays text values in results without the enclosing quotes. Also see [[Numbers and text|Converting number to text]].&lt;br /&gt;
&lt;br /&gt;
For comparison and sort order for text, see [[Operators|Alphabetic ordering of text values]]. For functions that work with text values, see [[Text functions]].&lt;br /&gt;
&lt;br /&gt;
For converting between numbers and text, see [[Numbers and text]].&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Operators#Alphabetic ordering of text values|Alphabetic ordering of text values]]&lt;br /&gt;
* [[Text functions]]  &lt;br /&gt;
* [[IsText]] &lt;br /&gt;
* [[Text Concatenation Operator: &amp;amp;]]&lt;br /&gt;
* [[Converting Numbers to Text]]&lt;br /&gt;
* [[Numbers and text]]&lt;br /&gt;
* [[Read and write text files]]&lt;br /&gt;
* [[Graphics, frames, and text in a diagram]]&lt;br /&gt;
* [[Objects and values]]&lt;br /&gt;
* [[Choice]]&lt;br /&gt;
* [[Multiple formats in one table]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Boolean or truth values / {{PAGENAME}} / Operators&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Converting_Numbers_to_Text&amp;diff=48535</id>
		<title>Converting Numbers to Text</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Converting_Numbers_to_Text&amp;diff=48535"/>
		<updated>2016-08-23T00:02:44Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Styles and options]]&lt;br /&gt;
&lt;br /&gt;
To convert a number to a text value, you can use [[Text Concatenation Operator: &amp;amp;|string concatenation]], e.g., &amp;lt;code&amp;gt;&amp;quot;&amp;quot; &amp;amp; x&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;quot;&amp;quot; &amp;amp; (2^10) &amp;amp;rarr; '1024'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;quot;&amp;quot; &amp;amp; Pi &amp;amp;rarr; '3.142'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;&amp;quot;&amp;quot; &amp;amp; Exp(10) &amp;amp;rarr; '22.03K'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The coercion uses the number format for the object that contains the expression being evaluated.  So, to use a different number format for the coercion, you must set the number format for that object.  &lt;br /&gt;
&lt;br /&gt;
To avoid confusion between the format for displaying results and the format used for number-to-text conversion, a better way to perform the conversion is to define a [[User-Defined Function]] for the specific number format you are interested in.  For example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Function NumberToYYYY_MMM_DD(x) := &amp;quot;&amp;quot; &amp;amp; x&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;{ Set its number format to Date &amp;amp;rarr; Custom &amp;amp;rarr; YYYY-MMM-DD }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Function NumberToDollars(x) := &amp;quot;&amp;quot; &amp;amp; x&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;{ Set its number format to Fixed Point, currency, two digits, show trailing zeroes }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With these, you can now accomplish the desired coercions using these functions.  The number format for the function determines the conversion, rather than the number format for your variable.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Function_Parameter_Qualifiers#Coerce_.3Ctype.3E|Coerce function parameter qualifier]]&lt;br /&gt;
* [[Numbers]]&lt;br /&gt;
* [[Numbers and text]]&lt;br /&gt;
* [[NumberToText]]&lt;br /&gt;
* [[ParseNumber]]&lt;br /&gt;
* [[ParseDate]]&lt;br /&gt;
* [[Number Format Dialog]]&lt;br /&gt;
* [[User-Defined Functions]]&lt;br /&gt;
* [[Math functions]]&lt;br /&gt;
* [[Text functions]]&lt;br /&gt;
* [[Multiple formats in one table]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Text_functions&amp;diff=48534</id>
		<title>Text functions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Text_functions&amp;diff=48534"/>
		<updated>2016-08-23T00:02:18Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
[[Category: Text Functions]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Text, Date, Math, and Financial Functions &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
These functions work with [[text values]] (sometimes known as strings), available in the built-in Text library.&lt;br /&gt;
&lt;br /&gt;
==Asc(t)==&lt;br /&gt;
Returns the ASCII code (a number between 0 and 255) of the first character in text value «t». This is occasionally useful, for example to understand the alphabetic ordering of text values.&lt;br /&gt;
&lt;br /&gt;
See also [[Asc]](t).&lt;br /&gt;
&lt;br /&gt;
==Chr(n)==&lt;br /&gt;
Returns the character corresponding to the numeric ASCII code «n» (a number between 0 and 255). [[Chr]]() and [[Asc]]() are inverses of each other, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Chr(65) &amp;amp;rarr; 'A', Asc(Chr(65)) &amp;amp;rarr; 65&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Asc('A') &amp;amp;rarr; 65, Chr(Asc('A')) &amp;amp;rarr; 'A'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Chr]]() is useful for creating characters that cannot easily be typed, such as ''Tab'', which is &amp;lt;code&amp;gt;Chr(9)&amp;lt;/code&amp;gt; and ''carriage return (CR)'', which is &amp;lt;code&amp;gt;Chr(13)&amp;lt;/code&amp;gt;. For example, if you read in a text file, &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;, you can use&lt;br /&gt;
&amp;lt;code&amp;gt;SplitText(x, Chr(13))&amp;lt;/code&amp;gt; to generate an array of lines from a multiline text file.&lt;br /&gt;
&lt;br /&gt;
==TextLength(t)==&lt;br /&gt;
Returns the number of characters in text «t».&lt;br /&gt;
&lt;br /&gt;
See also [[TextLength]]().&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;TextLength('supercalifragilisticexpialidocious') &amp;amp;rarr; 34&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SelectText(t, m, n)==&lt;br /&gt;
Returns text containing the «m»'th through the «n»'th character of text «t» (where the first character is «m»=1). If «n» is omitted it returns characters from the «m»'th through the end of «t».&lt;br /&gt;
&lt;br /&gt;
See also [[SelectText]]().&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SelectText('One or two', 1, 3) &amp;amp;rarr; 'One'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;SelectText('One or two', 8) &amp;amp;rarr; 'two'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===FindInText(substr, text, ''start, caseInsensitive, re, return, subpattern, repeat, repeatSubpattern, repeatIndex'')===&lt;br /&gt;
Returns the position of the first occurrence of «substr» within «text», as the number of characters to the first character of text. If it can't find «substr» in text, it returns 0.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable People := 'Amy, Betty, Carla'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('Amy', People) &amp;amp;rarr; 1&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('Betty', People) &amp;amp;rarr; 6&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('Fred', People) &amp;amp;rarr; 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Optional parameters ===&lt;br /&gt;
&lt;br /&gt;
==== CaseInsensitive ====&lt;br /&gt;
[[FindInText]]() is case-sensitive unless the optional parameter «caseInsensitive» is true:&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('amy', People) &amp;amp;rarr; 0&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('amy', People, caseInsensitive: true) &amp;amp;rarr; 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start ====&lt;br /&gt;
The optional third parameter, «start», specifies the position to start searching at, for example, if you want to find a second occurrence of «substr» after you have found the first one.&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('i','Supercalifragilisticexpialidocious') &amp;amp;rarr; 9&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('i','Supercalifragilisticexpialidocious', 10) &amp;amp;rarr; 14&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Repeat, RepeatIndex ====&lt;br /&gt;
Normally [[FindInText]]() returns information on the first match, but by using any of the three optional repeat parameters can be used to find all matches in text. When it finds multiple matches, the result is an array. If you specify&amp;lt;code&amp;gt;repeat: true&amp;lt;/code&amp;gt;, the resulthas a local index named &amp;lt;code&amp;gt;.Repeat&amp;lt;/code&amp;gt; with elements &amp;lt;code&amp;gt;1..n&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Alternatively, you can specify a preexisting index as «repeatIndex» parameter. If that index has ''n'' elements, it returns only the first ''n'' matches. &lt;br /&gt;
&lt;br /&gt;
This example parses XML text, returning an array of ages with a local index named «.Name», where the labels of the local index are the names of each person:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('&amp;lt;person.*?name = &amp;quot;(?&amp;lt;name&amp;gt;(.*?))&amp;quot;.*?&amp;gt;.*?' &amp;amp; '&amp;lt;age&amp;gt;(?&amp;lt;age&amp;gt;.*?)&amp;lt;/age&amp;gt;.*?' &amp;amp; '&amp;lt;/person&amp;gt;', xmlText, re: true, return: 'S', repeatSubpattern: 'name', subpattern: 'age')&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Re (Regular expression), Return, and Subpattern ====&lt;br /&gt;
&lt;br /&gt;
If you set optional parameter, «re», to &amp;lt;code&amp;gt;True,&amp;lt;/code&amp;gt;it interprets «substr» as a ''regular expression''. The regular expression language is widely used (not just in Analytica) to specify match criteria for text. It offers &amp;quot;wild cards&amp;quot; that match any letter, digit, or other character, identify separate words, and a lot more. See [[Regular expression]]s for details.&lt;br /&gt;
&lt;br /&gt;
Parentheses within a regular expression denote subpatterns, numbered in a depth first fashion. Subpatterns can also be named using the regular expression format “&amp;lt;code&amp;gt;(?&amp;lt;name&amp;gt;...)&amp;lt;/code&amp;gt;”. You can the match information for any subpattern by specifying the subpattern number or subpattern name in the optional «subpattern» parameter.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('d.*T', 'FindInText', re:1) &amp;amp;rarr; 4&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('d.*T', 'FindInText', re: 1, return:['L', 'S']) &amp;amp;rarr; [4, 'dInT']&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('(\d\d\d)-(\d\d\d\d)', '650-212-1212', re:1, return:’S’,  subpattern:[0, 1, 2]) &amp;amp;rarr; ['212-1212', ’212’, ’1212’]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;FindInText('a*(?&amp;lt;bcd&amp;gt;b+(c+)(d*))','zyabdaabbcccfd', re:1, subpattern:['bcd', 0, 1, 2, 3]) &amp;amp;rarr; [8, 6, 8, 10, 13]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The «return» parameter alters what is returned, according to what letter you provide as the parameter:&lt;br /&gt;
&lt;br /&gt;
* ‘P’ (or ‘Position’): The position of the matching text or subpattern (default)&lt;br /&gt;
* ‘L’ (or ‘Length’): The length of the matching text or subpattern.&lt;br /&gt;
* 'S’ (or ‘Subpattern’): The text matched the regular expression or subpattern.&lt;br /&gt;
* ‘#’ (or ‘#Subpatterns’): The number of subpatterns in the regular expression.&lt;br /&gt;
&lt;br /&gt;
==TextTrim(t, ''leftOnly, rightOnly, trimChars'')==&lt;br /&gt;
Removes leading and trailing spaces from the text «t». &lt;br /&gt;
:&amp;lt;code&amp;gt;TextTrim(' Hello World ') &amp;amp;rarr; 'Hello World'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set optional parameter  «leftOnly» to True to remove only preceding spaces,  or set «rightOnly» to True to remove only followingspaces:&lt;br /&gt;
:&amp;lt;code&amp;gt;TextTrim(' Hello World ', leftOnly: True) &amp;amp;rarr; 'Hello World'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TextTrim(' Hello World ', rightOnly: True) &amp;amp;rarr; ' Hello World'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To remove characters other than spaces, specify those characters in a text for  the optional «trimChars» parameter:&lt;br /&gt;
:&amp;lt;code&amp;gt;TextTrim(' [One, Two, Three] ', trimChars: ' []') &amp;amp;rarr; 'One, Two, Three'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==TextReplace(text, pattern, substr, ''all, caseInsensitive, re'')==&lt;br /&gt;
Returns text with the first occurrence of «pattern» replaced by «substr».&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;TextReplace('StringReplace, StringLength', 'String', 'Text') &amp;amp;rarr; 'TextReplace, StringLength'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If «all» is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;, it returns «text» with ''all'' occurrences of text «pattern» replaced by «subst».&lt;br /&gt;
:&amp;lt;code&amp;gt;TextReplace('StringReplace, StringLength', 'String', 'Text', All: True) &amp;amp;rarr; 'TextReplace, TextLength'&amp;lt;/code&amp;gt;&lt;br /&gt;
Matches are case-sensitive unless «caseInsensitive» is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Re (Regular expression) ====&lt;br /&gt;
When the optional «re» parameter is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;, it treats «pattern» as a [[regular expression]]. In this mode, it replaces the character sequence &amp;lt;code&amp;gt;\0&amp;lt;/code&amp;gt; in «subst» by the matching text, and it replaces &amp;lt;code&amp;gt;\1, \2, ..., \9&amp;lt;/code&amp;gt;  by the subtext matched by the corresponding numbered subpattern in the regular expression. The character sequence &amp;lt;code&amp;gt;''&amp;lt;name&amp;gt;''&amp;lt;/code&amp;gt; in «subst» is replaced by the subtext matched to the indicated named subpattern.&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;TextReplace('Hello world', '\w+', '«\0»', all:True, re: True) &amp;amp;rarr; '«Hello» «world»'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TextReplace('Hello world', '(.{1, 7}).*', '\1…', re: True) &amp;amp;rarr; 'Hello w…'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TextReplace(text: 'swap first and last', pattern: '(?&amp;lt;first&amp;gt;\w+)(?&amp;lt;mid&amp;gt;.*)(?&amp;lt;last&amp;gt;\b\w+)', subst:'&amp;lt;last&amp;gt;&amp;lt;mid&amp;gt;&amp;lt;first&amp;gt;', re: True) &amp;amp;rarr; 'last first and swap’&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TextReplace('swap first and last', '(\w)(\w*)(\w)', '\3\2\1', re: 1, all: 1 ) &amp;amp;rarr; 'pwas tirsf dna tasl'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Joining Text: a &amp;amp; b==&lt;br /&gt;
The [[Text_Concatenation_Operator%3A_%26|&amp;amp;]] operator joins (concatenates) two text values to form a single text value, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;'What is the' &amp;amp; ' number' &amp;amp; '?' &amp;amp;rarr; 'What is the number?'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If one or both operands are numbers, it converts them to text using the number format of the variable whose definition contains this function call (or the default suffix format if none is set), for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;'The number is ' &amp;amp; 10^8 &amp;amp;rarr; 'The number is 100M'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is also useful for converting (or “coercing”) numbers to text.&lt;br /&gt;
&lt;br /&gt;
==JoinText(a, i, ''separator, finalSeparator, default, textForNull'')==&lt;br /&gt;
Returns the elements of array «a» joined together into a single text value over index «i». If elements of «a» are numeric, [[JoinText]]() first converts them to text using the number format settings for the variable whose definition contains this function call. For example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;I := ['A', 'B', 'C']&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(I, I) &amp;amp;rarr; 'ABC'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;A := Array(I, ['VW', 'Honda', 'BMW'])&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;B := Array(I, ['VW', Null, 'BMW'])&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(A, I) &amp;amp;rarr; 'VWHondaBMW'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the optional parameter «separator» is specified, it is inserted as a separator between successive elements, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(A, I, ', ') &amp;amp;rarr; 'VW, Honda, BMW'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The optional parameter «finalSeparator», if present, specifies a different separator between the second-to-last and last elements of «a».&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(A, I, '; ', '; and') &amp;amp;rarr; 'VW; Honda; and BMW'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Null values in «a» are ignored unless the optional parameter «textForNull» is specified.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(B, I, ', ') &amp;amp;rarr; 'one, two'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(B, I, ', ', textForNull: '') &amp;amp;rarr; 'one, , two'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(B, I, ',  ' , textForNull: 'NULL') &amp;amp;rarr; 'one, NULL, two'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The optional «default» parameter is returned when all values are ignored, or «a» has a zero length.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText([Null, Null, Null], default: Null) &amp;amp;rarr; «null»&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SplitText(text, separator, ''caseInsensitive, re'')==&lt;br /&gt;
Returns a list of text values formed by splitting the elements of text value text at each occurrence of separator «separator». For example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SplitText('VW, Honda, BMW', ', ') &amp;amp;rarr; ['VW', 'Honda', 'BMW']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[SplitText]]() is the inverse of [[JoinText]](), if you use the same separators. For example:&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;Var x := SplitText('Humpty Dumpty sat on a wall.', ' ') &amp;amp;rarr; ['Humpty', 'Dumpty', 'sat', 'on', 'a', 'wall.']&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;JoinText(x,  , ' ') &amp;amp;rarr; 'Humpty Dumpty sat on a wall.'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When «separator» contains letters, setting «caseInsensitive» to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; matches in a lower/uppercase-insensitive manner. When the «re» parameter is &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;, separator is interpreted as a Perl-compatible [[regular expression]].&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;Variable s := 'Yes, Virginia. There is a Santa Claus!'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;SplitText(s, '[\s, \.!]+', re: 1) &amp;amp;rarr; ['Yes', 'Virginia', 'There', 'is', 'a', 'Santa', 'Claus', '']&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;SplitText(TextTrim(s, trimChars: ' , .!'), '[\s, \.!]+', re:1) &amp;amp;rarr; ['Yes', 'Virginia', 'There', 'is', 'a', 'Santa', 'Claus']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title=&amp;quot;Tip&amp;gt; With [[SplitText]](), «text» must be a single text value, not an array. Otherwise, it might generate an array of arrays of different length. See [[Ensuring Array Abstraction|Functions expecting atomic parameters]] on what to do if you want apply it to an array.&lt;br /&gt;
&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==TextLowerCase(t)==&lt;br /&gt;
[[TextLowerCase]]() returns the text «t» with all letters as lowercase. For example:&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;TextLowerCase('What does XML mean?') &amp;amp;rarr;  'what does xml mean?'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==TextUpperCase(t)==&lt;br /&gt;
[[TextUpperCase]]() returns the text «t» with all letters as uppercase. For example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;TextUpperCase('What does XML mean?') &amp;amp;rarr; 'WHAT DOES XML MEAN?'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==TextSentenceCase(Text, ''preserveUC'')==&lt;br /&gt;
[[TextSentenceCase]]() returns the text «t» with the first character (if a letter) as uppercase, and any other letters as lowercase. For example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;TextSentenceCase('mary ann FRED Maylene') &amp;amp;rarr;  'Mary ann fred maylene'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TextSentenceCase(SplitText('mary ann FRED Maylene', ' ')) &amp;amp;rarr; ['Mary', 'Ann', 'Fred', 'Maylene']&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TextSentenceCase('they are Fred and Maylene', true) &amp;amp;rarr; 'They are Fred and Maylene'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==NumberToText(x, format)==&lt;br /&gt;
&lt;br /&gt;
NumberToText() converts number «x» to text using the specified «format». It provides all the settings and options available in the [[Number formats]] dialog for displaying a number (including a date number). &lt;br /&gt;
&lt;br /&gt;
Possible values for «format» are: &amp;lt;code&amp;gt;'Suffix', 'Exponential', 'Fixed Point', 'Integer', 'Percent', 'Date', 'Boolean'&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;'Hexadecimal'&amp;lt;/code&amp;gt;. You can just use the first letter of a format to keep it brief:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(3.45M, ['S', 'E', 'F', 'I', 'H']) &amp;amp;rarr; ['3.45M', '3.45.e+006', '3450000', '3450000', '0x34a490']&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(0.0012, ['S', 'E', 'F', 'P']) &amp;amp;rarr; ['1.2m', '1.2e-003', '0', 0.12%']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NumberToText() offers these optional parameters:&lt;br /&gt;
&lt;br /&gt;
*«digits» specifies the precision for Suffix and Exponential formats, and the digits to the right of the decimal for Fixed Point and Percent formats, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(Pi, 'Suffix', digits: 5) &amp;amp;rarr; '3.1416'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(Pi, 'Fixed Point', digits: 5) &amp;amp;rarr; '3.14159'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(Pi, 'Percent', digits: 5) &amp;amp;rarr; '314.15927%'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* «showZeros» forces the inclusion of trailing zeros:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(1/4, 'Percent', digits: 2, showZeros: True) &amp;amp;rarr; '25.00%'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set «thousandsSeparators» to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to separate digits into groups of three:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(7^12,'I',  thousandsSeparators: True) &amp;amp;rarr; '13,841, 287, 201'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* «currency» specifies a template with the currency symbol and its placement relative to the number and the minus sign.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(-372, 'F', currency: ['-£#', 'US$-#', '#£-', '($#)']) &amp;amp;rarr; ['-£372', 'US$-372', '372£-', '($372)']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* «dateFormat» provides a date format template for converting [[date numbers]] to text:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(Today(), dateFormat: 'yyyy MMMM dd (wwww)') &amp;amp;rarr; '2013 July 01 (Monday)'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* «fullPrecision»: Set this to true, to include all digits to ensure that the full precision of the number.&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;NumberToText(Pi, fullPrecision: True) &amp;amp;rarr; '3.141592653589793'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ParseNumber(text, ''badVal'') ==&lt;br /&gt;
&lt;br /&gt;
Parses a text value into a number. (For dates, use [[ParseDate]]()). The result is independent of the number format setting. Values that are already numeric are returned. If the number is unparseable, it returns &amp;lt;code&amp;gt;Null&amp;lt;/code&amp;gt;, unless you specify a different value to the optional parameter «badVal».&lt;br /&gt;
 &lt;br /&gt;
:&amp;lt;code&amp;gt;ParseNumber('12.43K') &amp;amp;rarr; 12.43K&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ParseNumber('hello') &amp;amp;rarr; «null»&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;ParseNumber(14.3) &amp;amp;rarr; 14.3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 If you use &amp;lt;code&amp;gt;ParseNumber(x, x)&amp;lt;/code&amp;gt; it will simply return any unparseable text values in «x» as the original text value:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;VAR x := ['3, 214', 14, 'foo'] DO ParseNumber(x, x) &amp;amp;rarr; [ 3214, 14, 'foo']&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:2;-moz-column-count:2;-webkit-column-count:2&amp;quot;&amp;gt;&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
* [[Asc]]()&lt;br /&gt;
* [[Chr]]()&lt;br /&gt;
* [[TextLength]]()&lt;br /&gt;
* [[SelectText]]()&lt;br /&gt;
* [[ FindInText]]()&lt;br /&gt;
* [[TextTrim]]()&lt;br /&gt;
* [[TextReplace]]()&lt;br /&gt;
* [[Text Concatenation Operator: &amp;amp;]]&lt;br /&gt;
* [[JoinText]]()&lt;br /&gt;
* [[SplitText]]()&lt;br /&gt;
* [[TextLowerCase]]()&lt;br /&gt;
* [[TextUpperCase]]()&lt;br /&gt;
* [[TextSentenceCase]]()&lt;br /&gt;
* [[NumberToText]]()&lt;br /&gt;
* [[Numbers and text]]&lt;br /&gt;
* [[Converting Numbers to Text]]&lt;br /&gt;
* [[ParseNumber]]()&lt;br /&gt;
* [[Model File Character Encoding]]&lt;br /&gt;
* [[Read and write text files]]&lt;br /&gt;
* [[Files and Editing]]&lt;br /&gt;
* [[Multiple formats in one table]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Text, Date, Math, and Financial Functions / {{PAGENAME}} / Date functions&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Number_formats&amp;diff=48533</id>
		<title>Number formats</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Number_formats&amp;diff=48533"/>
		<updated>2016-08-23T00:01:04Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica User Guide]] &lt;br /&gt;
[[Category: Windows and dialogs]] &lt;br /&gt;
[[Category:Number formats]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Number and table formats &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setting the number format==&lt;br /&gt;
The '''Number format '''dialog lets you set the format of numbers and dates displayed in tables, graphs, and input or output fields. You can select options like the number of decimal digits, currency signs, and commas to separate thousands. The default number format is '''''suffix''''', which uses a letter after the number to denote order of magnitude -- for example, 10K means 10,000, where ''K ''means Kilo or thousands.&lt;br /&gt;
&lt;br /&gt;
Number format sets the format of a variable wherever it appears — in an [[Table|edit table]], [[Table view of a result|result table]], [[Graph view of a result|graph]], or field of a [[User input nodes and user output nodes|user input, or output]]. The number format of an [[Arrays and Indexes|index]] applies wherever that index is used, including row or column headers of a table, or graph axis that uses that index.&lt;br /&gt;
&lt;br /&gt;
You can enter a number into an [[Expression Assist|expression]] or table in any format, no matter what output format it uses.&lt;br /&gt;
&lt;br /&gt;
To set the number format for a variable:&lt;br /&gt;
&lt;br /&gt;
# Select a variable to format by showing its edit table, result table, or graph, or by selecting its node in a diagram. You can apply the same format to several variables if you select their nodes together in a diagram.&lt;br /&gt;
# Select '''Number format '''from the [[Result menu]], or press ''Control+b'', to show this dialog:&amp;lt;br&amp;gt;&lt;br /&gt;
:[[File:Chapter7_1.png]]&lt;br /&gt;
&amp;lt;ol start=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Select the format type you want from the list on the left.&lt;br /&gt;
&amp;lt;li&amp;gt; Select options you want, such as '''''Decimal digits''''', '''''Show trailing zeroes''''', '''''Thousands separators''''', or '''''Show currency symbol''''', from the menus and checkboxes. The options available depend on which format you selected.&lt;br /&gt;
&amp;lt;li&amp;gt; View the example at the top of the dialog to see if the format is what you want.&lt;br /&gt;
&amp;lt;li&amp;gt; If so, click the '''Apply '''button.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can change the default number format by pressing '''Set Default'''. The default format applies to all variables in your model whose number format has not been explicitly set.&lt;br /&gt;
&lt;br /&gt;
'''Format types''': Choose one of these number formats:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Format&lt;br /&gt;
!Description&lt;br /&gt;
!Example&lt;br /&gt;
|-&lt;br /&gt;
! Suffix&lt;br /&gt;
|A letter after the number specifies power of ten&lt;br /&gt;
|12.35K&lt;br /&gt;
|-&lt;br /&gt;
! Exponential&lt;br /&gt;
|Scientific notation, where the number after 'e' gives &lt;br /&gt;
the powers of ten&lt;br /&gt;
|1.2345e04&lt;br /&gt;
|-&lt;br /&gt;
! Fixed Point&lt;br /&gt;
|Number with a fixed number of digits after the decimal point&lt;br /&gt;
|12345.68&lt;br /&gt;
|-&lt;br /&gt;
! Integer&lt;br /&gt;
|A whole number with no decimals shown&lt;br /&gt;
|12346&lt;br /&gt;
|-&lt;br /&gt;
! Date&lt;br /&gt;
|Show number (days since 1 Jan 1900) as a date and/or time &lt;br /&gt;
(see below for format options)&lt;br /&gt;
|12 Jan 2007&lt;br /&gt;
|-&lt;br /&gt;
! Boolean&lt;br /&gt;
|Display 0 as '''&amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt;''', and any other number as '''&amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;'''&lt;br /&gt;
|True, False&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Suffix number format ====&lt;br /&gt;
Suffix is Analytica’s default number format. It uses a conventional letter after each number to specify powers of 10: 12K means 12,000 ('''''K''' ''for kilo or thousands), 2.5M means 2,500,000 ('''''M''' ''for Mega or millions), 5n means 0.000,000,005 ('''''n''' ''means nano or billionths). Here are the suffix characters:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Power of 10&lt;br /&gt;
!Suffix&lt;br /&gt;
!Prefix&lt;br /&gt;
| rowspan=&amp;quot;7&amp;quot; |&lt;br /&gt;
!Power of 10&lt;br /&gt;
!Suffix&lt;br /&gt;
!Prefix&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
!10&amp;lt;sup&amp;gt;-2&amp;lt;/sup&amp;gt;&lt;br /&gt;
|%&lt;br /&gt;
|percent&lt;br /&gt;
|-&lt;br /&gt;
!10&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&lt;br /&gt;
|K&lt;br /&gt;
|Kilo&lt;br /&gt;
!10&amp;lt;sup&amp;gt;-3&amp;lt;/sup&amp;gt;&lt;br /&gt;
|m&lt;br /&gt;
|milli&lt;br /&gt;
|-&lt;br /&gt;
!10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;&lt;br /&gt;
|M&lt;br /&gt;
|Mega or Million&lt;br /&gt;
!10&amp;lt;sup&amp;gt;-6&amp;lt;/sup&amp;gt;&lt;br /&gt;
|μ or u&lt;br /&gt;
|micro (mu)&lt;br /&gt;
|-&lt;br /&gt;
!10&amp;lt;sup&amp;gt;9&amp;lt;/sup&amp;gt;&lt;br /&gt;
|G or B&lt;br /&gt;
|Giga or Billion&lt;br /&gt;
!10&amp;lt;sup&amp;gt;-9&amp;lt;/sup&amp;gt;&lt;br /&gt;
|n&lt;br /&gt;
|nano&lt;br /&gt;
|-&lt;br /&gt;
!10&amp;lt;sup&amp;gt;12&amp;lt;/sup&amp;gt;&lt;br /&gt;
|T&lt;br /&gt;
|Tera or Trillion&lt;br /&gt;
!10&amp;lt;sup&amp;gt;-12&amp;lt;/sup&amp;gt;&lt;br /&gt;
|p&lt;br /&gt;
|pico&lt;br /&gt;
|-&lt;br /&gt;
!10&amp;lt;sup&amp;gt;15&amp;lt;/sup&amp;gt;&lt;br /&gt;
|Q&lt;br /&gt;
|Quadrillion&lt;br /&gt;
!10&amp;lt;sup&amp;gt;-15&amp;lt;/sup&amp;gt;&lt;br /&gt;
|f&lt;br /&gt;
|femto&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title=&amp;quot;Tip&amp;quot;&amp;gt;Note the difference between “M” for Mega or Million and “m” for milli (1/1000). This is the only situation in which Analytica cares about the difference between uppercase and lowercase. Otherwise, it is insensitive to case (except when matching text values).&amp;lt;/tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title=&amp;quot;Tip&amp;quot;&amp;gt;In suffix format, it displays four-digit numbers without the “K” suffix — e.g., 2010, not 2.010K — which works better for years. For suffix, integer, or fixed point formats, it uses exponent format for numbers too large or small — e.g., numbers larger than 109 in integer or fixed point format, or larger than 1018 in suffix format.&amp;lt;/tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Maximum precision''': The maximum number of digits including decimal digits is 15 (14 for fixed point and percent). The maximum precision is 15 digits (9 for integers).&lt;br /&gt;
&lt;br /&gt;
==Number format options ==&lt;br /&gt;
'''Decimal digits''': The number of digits to show after the decimal point.&lt;br /&gt;
&lt;br /&gt;
'''Show trailing zeroes''': Check to show trailing zeroes in decimals, e.g., 2.100 instead of 2.1, when decimal digits are set to 3.&lt;br /&gt;
&lt;br /&gt;
'''Thousands separators''': Check to show commas between every third digit of the integer part, e.g., 12,345.678, instead of 12345.678.&lt;br /&gt;
&lt;br /&gt;
'''Show currency symbol''': Check to show a currency symbol. Select the symbol and placement from these menus.&lt;br /&gt;
&lt;br /&gt;
[[File:Chapter7_4.png]]&lt;br /&gt;
&lt;br /&gt;
Placement controls the relative location of the currency symbol, e.g., '''$200 '''or '''200DM''', and whether to use a minus sign '''-$200 '''or parentheses '''($200) '''to indicate a negative number.&lt;br /&gt;
&lt;br /&gt;
'''Regional settings''': If you select the last entry, '''regional''', from the '''Symbol '''or '''Placement '''menu, it uses, respectively, the regional currency or placement settings set for your computer. You can modify these settings in the '''Regional and Language '''options available from the Windows Control Panel.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:2;-moz-column-count:2;-webkit-column-count:2&amp;quot;&amp;gt;&lt;br /&gt;
* [[Number Format Dialog]]&lt;br /&gt;
* [[NumberFormat]] attribute&lt;br /&gt;
* [[Numbers]]&lt;br /&gt;
* [[Data_Type_Functions#Function_IsNumber|IsNumber]]&lt;br /&gt;
* [[NaN|Not a Number]]&lt;br /&gt;
* [[Complex Numbers]]&lt;br /&gt;
* [[Binary and hexadecimal integer formats]]&lt;br /&gt;
* [[ReadBinaryFile]]&lt;br /&gt;
* [[WriteBinaryFile]]&lt;br /&gt;
* [[BitAnd]]&lt;br /&gt;
* [[NumberToText]]&lt;br /&gt;
* [[Numbers and text]]&lt;br /&gt;
* [[ParseNumber]]&lt;br /&gt;
* [[Result menu]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Number and table formats / {{PAGENAME}} / Date formats&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multiple_formats_in_one_table&amp;diff=48532</id>
		<title>Multiple formats in one table</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multiple_formats_in_one_table&amp;diff=48532"/>
		<updated>2016-08-23T00:00:01Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Number and table formats&amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Usually, the same [[Number formats|number format]] applies to all numbers in a table (except its index values in column or row headers, which use the format set for the index variable). Sometimes, you might want to use different formats for different rows (more generally, [[slice]]s) of a table. You can do this if you define the table as a list of variables, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Index Years := 2007..2012&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable DollarX := Table(Years)(...) { Formatted as dollars }&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable PercentX := DollarX/40K { Formatted as percent }&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable MultiformatX := [DollarX, PercentX]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;MultiformatX &amp;amp;rarr;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:Chapter7_8.png]]&lt;br /&gt;
&lt;br /&gt;
This table uses the number format set for each variable responsible for a row here — as long as you don’t override their settings by setting a format for &amp;lt;code&amp;gt;MultiformatX&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Number formats]]&lt;br /&gt;
* [[Creating Arrays (Tables)]]&lt;br /&gt;
* [[Tutorial: Arrays]]&lt;br /&gt;
* [[Table]]&lt;br /&gt;
* [[Slice]]&lt;br /&gt;
* [[Numbers and text]]&lt;br /&gt;
* [[Datatype functions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Display of constraint results / {{PAGENAME}} / Graphs&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Numbers_and_text&amp;diff=48531</id>
		<title>Numbers and text</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Numbers_and_text&amp;diff=48531"/>
		<updated>2016-08-22T23:58:14Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressions &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Converting number to text''': If you apply the [[Text_Concatenation_Operator%3A_%26|&amp;amp;]] operator or [[JoinText]]() to numbers, they convert the numbers to text values, using the number format specified for the variable or function in whose definition they appear. You can use this effect to convert (“coerce”) numbers into text values, for example:&lt;br /&gt;
:&amp;lt;code&amp;gt;123456789 &amp;amp; '' &amp;amp;rarr; '123.5M'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;123456789 &amp;amp; '' &amp;amp;rarr; '$123,456,789.00'&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;'The date is: ' &amp;amp; 38345 &amp;amp;rarr; The date is: Thursday, December 25, 2008'&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title=&amp;quot;Tip&amp;quot;&amp;gt;The actual result depends on ''Number Format ''setting for the variable or function in whose definition the expression appears. The first example assumes the default ''Suffix ''format. The second assumes ''Fixed Point ''format, with currency and thousands separators checked, and two decimal digits. The third assumes the ''Long Date ''format. Use the [[Number format]] dialog on the [[Result menu]] to set the formats.&amp;lt;/tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also control the format used when converting numbers to text with the [[Text functions|NumberToText]] function.&lt;br /&gt;
&lt;br /&gt;
'''Converting text to number''': You can use the [[Evaluate]] function to convert a text representation of a number into an actual number, for example:&lt;br /&gt;
:&amp;lt;code&amp;gt;Evaluate('12350') &amp;amp;rarr; 12.35K&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Evaluate() can convert any number format that Analytica can handle in an expression— and no others. Thus, it can handle decimals, exponent format, dates, &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt;, a &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; at the start of a number (which it ignores), and letter suffixes, like &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
An alternative method, for converting text to a number is to use the &amp;lt;code&amp;gt;Coerce Number&amp;lt;/code&amp;gt; qualifier on a user-defined function. For example, you could define a user-defined function such as:&lt;br /&gt;
:&amp;lt;code&amp;gt;ParseNum(X: Coerce Number) := X&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Converting Numbers to Text]]&lt;br /&gt;
* [[NumberToText]]&lt;br /&gt;
* [[Numbers]]&lt;br /&gt;
* [[IsNumber]]&lt;br /&gt;
* [[IsText]]&lt;br /&gt;
* [[Math functions]]&lt;br /&gt;
* [[Text functions]]&lt;br /&gt;
* [[Read and write text files]]&lt;br /&gt;
* [[Multiple formats in one table]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Math functions / {{PAGENAME}} / INF, NAN, and NULL - Exception values&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Datatype_functions&amp;diff=48530</id>
		<title>Datatype functions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Datatype_functions&amp;diff=48530"/>
		<updated>2016-08-22T23:55:48Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
[[Category: Data Type Functions]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressions &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A value can be a number, text, [[Null]], or a reference. Integers, reals, Boolean, and date values, are all represented as numbers. You can use these functions from the [[Special_Functions_library|Special]] library of [[Definition menu]] to determine the type.&lt;br /&gt;
&lt;br /&gt;
'''IsNumber(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a number, including a boolean, date, [[INF]], [[NaN]], or complex. See also [[IsNumber]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(0) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(False) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(INF) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber('hi') &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(5) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber('5') &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(NAN) &amp;amp;rarr; True&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''IsText(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a text value. See also [[IsText]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;IsText('hello') &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsText(7) &amp;amp;rarr; False&amp;lt;/code&amp;gt; &lt;br /&gt;
:&amp;lt;code&amp;gt;IsText('7') &amp;amp;rarr; True&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''IsNaN(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is “not a number,” i.e., [[NaN]]. [[INF]] or regular numbers do not qualify, nor does a text or [[Null]]. See also [[IsNaN]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;0/0 &amp;amp;rarr; NAN&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN(0/0) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN(5) &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN(INF) &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN('Hello') &amp;amp;rarr; False&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''IsNull(x)''': To test if «x» is exactly [[Null]]. Returns false if «x» is an array. See also [[IsNull]]().&lt;br /&gt;
&lt;br /&gt;
'''x &amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt; NULL''': To test if an atomic «x» is [[Null]]. When «x» is an array, returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; for each element of the array.&lt;br /&gt;
&lt;br /&gt;
'''IsUndef(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if atomic «x» is [[Null]] or the internal value [[Undefined]] (usually indicating uncomputed). When «x» is an array, returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; for each element of the array. See also [[IsUndef]]().&lt;br /&gt;
&lt;br /&gt;
'''IsRealNumber(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; when «x» is a real number, including a boolean, date or [[INF]]. Returns &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; when «x» is a complex number or [[NaN]]. See also [[IsRealNumber]]().&lt;br /&gt;
&lt;br /&gt;
'''IsReference(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a reference to a value. See also [[IsReference]]().&lt;br /&gt;
&lt;br /&gt;
'''IsHandle(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a handle to an Analytica object. See also [[IsHandle]](x).&lt;br /&gt;
&lt;br /&gt;
'''TypeOf(x)''': Returns the type of expression «x» as a text value, usually one of &amp;lt;code&amp;gt;Number, Text, Reference&amp;lt;/code&amp;gt;, or [[Null]]. [[INF]] and [[NaN]] are both of type &amp;lt;code&amp;gt;&amp;quot;Number&amp;quot;&amp;lt;/code&amp;gt;. See also [[TypeOf]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf(2008) &amp;amp;rarr; &amp;quot;Number&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf('2008') &amp;amp;rarr; &amp;quot;Text&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf(INF) &amp;amp;rarr; &amp;quot;Number&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf(0/0) &amp;amp;rarr; &amp;quot;Number&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:2;-moz-column-count:2;-webkit-column-count:2&amp;quot;&amp;gt;&lt;br /&gt;
* [[Data Type Functions]]&lt;br /&gt;
* [[TypeOf]]&lt;br /&gt;
* [[IsNumber]]&lt;br /&gt;
* [[IsRealNumber]]&lt;br /&gt;
* [[IsNaN]]&lt;br /&gt;
* [[IsText]]&lt;br /&gt;
* [[IsReference]]&lt;br /&gt;
* [[IsHandle]]&lt;br /&gt;
* [[IsNull]]&lt;br /&gt;
* [[IsUndef]]&lt;br /&gt;
* [[Special Functions library]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Data_type_qualifiers| Data types of function parameters]]&lt;br /&gt;
* [[Multiple formats in one table]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Warnings / {{PAGENAME}} / Text, Date, Math, and Financial Functions&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multiple_formats_in_one_table&amp;diff=48529</id>
		<title>Multiple formats in one table</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multiple_formats_in_one_table&amp;diff=48529"/>
		<updated>2016-08-22T23:55:10Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Number and table formats&amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Usually, the same [[Number formats|number format]] applies to all numbers in a table (except its index values in column or row headers, which use the format set for the index variable). Sometimes, you might want to use different formats for different rows (more generally, [[slice]]s) of a table. You can do this if you define the table as a list of variables, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Index Years := 2007..2012&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable DollarX := Table(Years)(...) { Formatted as dollars }&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable PercentX := DollarX/40K { Formatted as percent }&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable MultiformatX := [DollarX, PercentX]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;MultiformatX &amp;amp;rarr;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:Chapter7_8.png]]&lt;br /&gt;
&lt;br /&gt;
This table uses the number format set for each variable responsible for a row here — as long as you don’t override their settings by setting a format for &amp;lt;code&amp;gt;MultiformatX&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Number formats]]&lt;br /&gt;
* [[Creating Arrays (Tables)]]&lt;br /&gt;
* [[Tutorial: Arrays]]&lt;br /&gt;
* [[Table]]&lt;br /&gt;
* [[Slice]]&lt;br /&gt;
* [[Datatype functions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Display of constraint results / {{PAGENAME}} / Graphs&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Multiple_formats_in_one_table&amp;diff=48528</id>
		<title>Multiple formats in one table</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Multiple_formats_in_one_table&amp;diff=48528"/>
		<updated>2016-08-22T23:55:00Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Number and table formats&amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Usually, the same [[Number formats|number format]] applies to all numbers in a table (except its index values in column or row headers, which use the format set for the index variable). Sometimes, you might want to use different formats for different rows (more generally, [[slice]]s) of a table. You can do this if you define the table as a list of variables, for example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Index Years := 2007..2012&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable DollarX := Table(Years)(...) { Formatted as dollars }&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable PercentX := DollarX/40K { Formatted as percent }&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable MultiformatX := [DollarX, PercentX]&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;MultiformatX &amp;amp;rarr;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:Chapter7_8.png]]&lt;br /&gt;
&lt;br /&gt;
This table uses the number format set for each variable responsible for a row here — as long as you don’t override their settings by setting a format for &amp;lt;code&amp;gt;MultiformatX&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Number formats]]&lt;br /&gt;
* [[Creating Arrays (Tables)]]&lt;br /&gt;
* [[Tutorial: Arrays]]&lt;br /&gt;
* [[Table]]&lt;br /&gt;
* [[Slice]]&lt;br /&gt;
* [[Datatype functions]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Display of constraint results / {{PAGENAME}} / Graphs&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Data_definitions&amp;diff=48527</id>
		<title>Data definitions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Data_definitions&amp;diff=48527"/>
		<updated>2016-08-22T23:54:34Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Multiple formats in one table&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Multiple formats in one table]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Selecting_the_Sample_Size&amp;diff=48526</id>
		<title>Selecting the Sample Size</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Selecting_the_Sample_Size&amp;diff=48526"/>
		<updated>2016-08-22T23:43:03Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; Analytica User Guide &amp;gt; Expressing Uncertainty &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each probabilistic value is simulated by computing a random sample of values from the actual probability distribution.&lt;br /&gt;
&lt;br /&gt;
You can control the sampling method (system variable [[SampleType]]) and sample size (system variable [[SampleSize]]) by using [[Uncertainty Setup dialog]]. The sections below discuss how to select a sample size.  &lt;br /&gt;
&lt;br /&gt;
==Choosing an Appropriate Sample Size==&lt;br /&gt;
&lt;br /&gt;
There is a clear trade-off for using a larger sample size in calculating an uncertainty variable. When you set the sample size to a large value, the result is less noisy, but it takes a longer time to compute the distribution. For an initial probabilistic calculation, a sample size of 20 to 50 is usually adequate.&lt;br /&gt;
&lt;br /&gt;
How should you choose the sample size «m»? It depends both on the cost of each model run, and what you want the results for. An advantage of the [[Monte Carlo]] method is that you can apply many standard statistical techniques to estimate the precision of estimates of the output distribution. This is because the generated sample of values for each output variable is a random sample from the true probability distribution for that variable.&lt;br /&gt;
&lt;br /&gt;
==Uncertainty about the Mean==&lt;br /&gt;
&lt;br /&gt;
First, suppose you are primarily interested in the precision of the [[mean]] of your output variable «y». Assume you have a random sample of «m» output values generated by [[Monte Carlo]] simulation:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(y_1, y_2, y_3, …y_m) &amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(1)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can estimate the mean and standard deviation of «y» using the following equations:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\vec y=\sum_{i=1}^m \frac { y_i }m&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(2)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;s^2=\sum_{i=1}^m \frac { (y_i - \vec y)^2} {m - 1}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(3)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This leads to the following confidence interval with confidence «α», where «c» is the deviation for the unit normally enclosing probability «α»:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\left (\vec y-c\frac {s} {\sqrt m}, \vec y + c\frac {s} {\sqrt m}\right ) &amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(4)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suppose you wish to obtain an estimate of the mean of «y» with an «α» confidence interval smaller than «w» units wide. What sample size do you need? You need to make sure that:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;w&amp;gt;2c \frac {s}{\sqrt m}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(5)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, rearranging the inequality:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m&amp;gt; \left ( \frac {2cs}{w}\right ) ^2&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(6)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use this, first make a small Monte Carlo run with, say, 10 values to get an initial estimate of the variance of «y» — that is, «s2». You can then use equation (6) to estimate how many samples reduce the confidence interval to the requisite width «w».&lt;br /&gt;
&lt;br /&gt;
For example, suppose you wish to obtain a 95% confidence interval for the mean that is less than 20 units wide. Suppose your initial sample of 10 gives ''s = 40''. The deviation «c» enclosing a probability of 95% for a unit normal is about 2. Substituting these numbers into equation (6), you get:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m&amp;gt; \left ( \frac {2 \times 2 \times 40}{20} \right )^2 = 8^2 = 64&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(7)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, to get the required precision for the mean, you should set the sample size to about 64.&lt;br /&gt;
&lt;br /&gt;
== Estimating Confidence Intervals for Fractiles ==&lt;br /&gt;
&lt;br /&gt;
Another criterion for selecting sample size is the precision of the estimate of the median and other fractiles, or more generally, the precision of the estimated cumulative distribution. Assume that the sample «m» values of «y» are relabeled so that they are in increasing order:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; y_1 \le, y_2 \le, ...y_m&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
«c» is the deviation enclosing probability «α» of the unit normal. Then the following pair of sample values constitutes the confidence interval:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(y_i, y_k)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = \left \lfloor mp - c \sqrt {mp (1-p)} \right \rfloor&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(8)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = \left \lceil mp - c \sqrt {mp (1-p)} \right \rceil&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(9)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Tip Title=&amp;quot;Note&amp;quot;&amp;gt; The brackets in equations (8) and (9) above mean round up [[File:lceil.png]] and round down[[File:rfloor.png]], since they are computing numbers that need to be integers.&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suppose you want to achieve sufficient precision such that the «a» confidence interval for the pth fractile «Y&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;» is given by (y&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, y&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;), where «y&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;» is an estimate of '''&amp;lt;math&amp;gt;{Y_p-{_\Delta}{_p}}&amp;lt;/math&amp;gt;''', and «y&amp;lt;sub&amp;gt;k&amp;lt;/sub&amp;gt;» is an estimate of '''&amp;lt;math&amp;gt;{Y_p+{_\Delta}{_p}}&amp;lt;/math&amp;gt;'''. In other words, you want «&amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;» confidence of «Y&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;» being between the sample values used as estimates of the (&amp;lt;math&amp;gt;p-{_\Delta}{_p})&amp;lt;/math&amp;gt;) and (&amp;lt;math&amp;gt;p+{_\Delta}{_p})&amp;lt;/math&amp;gt;) fractiles. What sample size do you need? Ignoring the rounding, you have approximately:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = m(p-{\Delta}p), k = m(p+{\Delta} p)&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(10)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;k - i = 2m{\Delta}p&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(11)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From equations (8) and (9) above, you have:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;k - i = 2c\sqrt {mp(1-p)}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(12)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equating the two expressions for ''k - 1'' , you obtain:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;2mp\Delta p = 2c \sqrt {mp(1-p)}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(13)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m=p(1- p) \left (\frac {c}{\Delta p} \right )^2&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(14)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, suppose you want to be 95% confident that the estimated fractile Y&amp;lt;sub&amp;gt;.90&amp;lt;/sub&amp;gt; is between the estimated fractiles Y&amp;lt;sub&amp;gt;.85&amp;lt;/sub&amp;gt; and Y&amp;lt;sub&amp;gt;.95&amp;lt;/sub&amp;gt;. So you have &amp;lt;math&amp;gt;\Delta p&amp;lt;/math&amp;gt; = 0.05, and ''c ≈ 2''. Substituting the numbers into equation (14), you get:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m = 0.90 \times  (1 - 0.90) \times \left (\frac {2}{0.05} \right )^2 = 144&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(15)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
On the other hand, suppose you want the credible interval for the least precise estimated percentile (the 50th percentile) to have a 95% confidence interval of plus or minus one estimated percentile. Then:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m = 0.5 \times  (1 - 0.5) \times \left (\frac {2}{0.01} \right )^2 = 10,000&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(16)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These results are completely independent of the shape of the distribution. If you find this an appropriate way to state your requirements for the precision of the estimated distribution, you can determine the sample size before doing ''any'' runs to see what sort of distribution it might be.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[SampleSize]]&lt;br /&gt;
* [[SampleType]]&lt;br /&gt;
* [[Sample]]&lt;br /&gt;
* [[Monte_Carlo_and_probabilistic_simulation#Monte_Carlo_sampling|Monte Carlo sampling]]&lt;br /&gt;
* [[Evaluation Modes]]&lt;br /&gt;
* [[Uncertainty Setup dialog]]&lt;br /&gt;
* [[Distribution Densities Library]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Uncertainty views / {{PAGENAME}} / Choosing an appropriate distribution&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=SampleSize&amp;diff=48525</id>
		<title>SampleSize</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=SampleSize&amp;diff=48525"/>
		<updated>2016-08-22T23:41:20Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:System Variables]]&lt;br /&gt;
&lt;br /&gt;
== SysVar SampleSize ==&lt;br /&gt;
&lt;br /&gt;
This system variable contains the current sample size used in [[Monte Carlo]] simulations.  You can use this value in expressions.  You can equivalently obtain the sample size using &amp;lt;code&amp;gt;Size(Run)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The sample size is changed using the [[Uncertainty Setup dialog]], which you can get to on the menu from [[Result menu|Result]] &amp;amp;rarr; '''Uncertainty Options...'' or by pressing ''Ctrl+U''.  Then select '''Analysis option: Uncertainty Sample'''.&lt;br /&gt;
&lt;br /&gt;
== Selecting a Sample Size ==&lt;br /&gt;
&lt;br /&gt;
How do you select the appropriate sample size for your problem?  &lt;br /&gt;
&lt;br /&gt;
There is a basic tradeoff when selecting sample size.  Larger sample sizes require longer evaluation times and more memory, while smaller sample sizes result in greater sampling error.  While perfecting your model's logic, you may want to use a very small sample size, even though the sampling error would be unacceptable, but then when you're ready to compute your final results, up the sample size accordingly.&lt;br /&gt;
&lt;br /&gt;
Most people substantially over-estimate the sample sizes they really need for good results for their specific problem.  This is partly because the appearance of [[PDF]] graphs are among the most sensitive to sampling error, and irregular appearance of [[PDF]] graphs often leads people to think they need very large sample sizes.  But even with choppy-looking [[PDF]]s, it may be the case that the sampling error for specific [[GetFract|fractile levels]], [[Mean|mean]] and [[SDeviation|standard deviations]] is quite small.&lt;br /&gt;
&lt;br /&gt;
However, if you are require extreme fractile levels, accurate higher-order moments (e.g., [[Skewness]], [[Kurtosis]]), or highly reliable sensitivity/importance estimates, it really may require very large sample sizes to achieve low sampling error.&lt;br /&gt;
&lt;br /&gt;
The best way to figure out the appropriate tradeoffs for your application is by experimentation designed to empirically measure and estimate your sampling error at particular sample sizes.  Select a fixed sample size, and then evaluate your key results.  Reset (e.g., but changing the sample size to something else, then resetting it back again) and repeat.  Do this several times to see how much your results vary from run to run.  By observing that variation, you are directly observing the sample error.  &lt;br /&gt;
&lt;br /&gt;
The experiment can automated (for each fixed sample size) by introducing an index and allowing array abstraction to repeat the experiment for you.  Your uncertain results will all be indexed by this new index, and you can directly view the variation across your results.  Doing this, however, requires that you add an «over» parameter to all your calls to distribution functions.  For example, if you have:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable X := Normal(a, b)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you'll need to change it to:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable X := Normal(a, b, over: meta_run)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and define your index:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Index Meta_run := 1..10&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Having done this, then you can examine your results of interest and see how these vary over the &amp;lt;code&amp;gt;Meta_run&amp;lt;/code&amp;gt; index.  This measures the observed sampling error in the fractile levels of interest:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Est_samp_err := SDeviation(ProbBands(My_result), Meta_run)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you surgically introduce &amp;lt;code&amp;gt;Meta_run&amp;lt;/code&amp;gt; into your model in this fashion, it turns out to be better to define &amp;lt;code&amp;gt;Meta_run&amp;lt;/code&amp;gt; as a variable object, rather than as an index.  If you do that, then you can easily change its definition to a scalar, e.g.:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Meta_run := 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you aren't performing this meta-analysis of sampling error.&lt;br /&gt;
&lt;br /&gt;
== Theoretical determination of Sample Size ==&lt;br /&gt;
&lt;br /&gt;
In many cases, you can also compute the &amp;quot;theoretical&amp;quot; sample size required with a little algebra.  This is detailed in the [[Selecting the Sample Size]] in the [[Analytica User Guide]].&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Run]]&lt;br /&gt;
* [[Sample]]&lt;br /&gt;
* [[SampleType]]&lt;br /&gt;
* [[Selecting the Sample Size]]&lt;br /&gt;
* [[ProbBands]]&lt;br /&gt;
* [[Uncertainty Setup dialog]]&lt;br /&gt;
* [[Monte Carlo and probabilistic simulation]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=SampleSize&amp;diff=48524</id>
		<title>SampleSize</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=SampleSize&amp;diff=48524"/>
		<updated>2016-08-22T23:40:08Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* SysVar SampleSize */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:System Variables]]&lt;br /&gt;
&lt;br /&gt;
== SysVar SampleSize ==&lt;br /&gt;
&lt;br /&gt;
This system variable contains the current sample size used in [[Monte Carlo]] simulations.  You can use this value in expressions.  You can equivalently obtain the sample size using &amp;lt;code&amp;gt;Size(Run)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The sample size is changed using the [[Uncertainty Setup dialog]], which you can get to on the menu from [[Result menu|Result]] &amp;amp;rarr; '''Uncertainty Options...'' or by pressing ''Ctrl+U''.  Then select '''Analysis option: Uncertainty Sample'''.&lt;br /&gt;
&lt;br /&gt;
== Selecting a Sample Size ==&lt;br /&gt;
&lt;br /&gt;
How do you select the appropriate sample size for your problem?  &lt;br /&gt;
&lt;br /&gt;
There is a basic tradeoff when selecting sample size.  Larger sample sizes require longer evaluation times and more memory, while smaller sample sizes result in greater sampling error.  While perfecting your model's logic, you may want to use a very small sample size, even though the sampling error would be unacceptable, but then when you're ready to compute your final results, up the sample size accordingly.&lt;br /&gt;
&lt;br /&gt;
Most people substantially over-estimate the sample sizes they really need for good results for their specific problem.  This is partly because the appearance of [[PDF]] graphs are among the most sensitive to sampling error, and irregular appearance of [[PDF]] graphs often leads people to think they need very large sample sizes.  But even with choppy-looking [[PDF]]s, it may be the case that the sampling error for specific [[GetFract|fractile levels]], [[Mean|mean]] and [[SDeviation|standard deviations]] is quite small.&lt;br /&gt;
&lt;br /&gt;
However, if you are require extreme fractile levels, accurate higher-order moments (e.g., [[Skewness]], [[Kurtosis]]), or highly reliable sensitivity/importance estimates, it really may require very large sample sizes to achieve low sampling error.&lt;br /&gt;
&lt;br /&gt;
The best way to figure out the appropriate tradeoffs for your application is by experimentation designed to empirically measure and estimate your sampling error at particular sample sizes.  Select a fixed sample size, and then evaluate your key results.  Reset (e.g., but changing the sample size to something else, then resetting it back again) and repeat.  Do this several times to see how much your results vary from run to run.  By observing that variation, you are directly observing the sample error.  &lt;br /&gt;
&lt;br /&gt;
The experiment can automated (for each fixed sample size) by introducing an index and allowing array abstraction to repeat the experiment for you.  Your uncertain results will all be indexed by this new index, and you can directly view the variation across your results.  Doing this, however, requires that you add an «over» parameter to all your calls to distribution functions.  For example, if you have:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable X := Normal(a, b)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you'll need to change it to:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable X := Normal(a, b, over: meta_run)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and define your index:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Index Meta_run := 1..10&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Having done this, then you can examine your results of interest and see how these vary over the &amp;lt;code&amp;gt;Meta_run&amp;lt;/code&amp;gt; index.  This measures the observed sampling error in the fractile levels of interest:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Est_samp_err := SDeviation(ProbBands(My_result), Meta_run)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you surgically introduce &amp;lt;code&amp;gt;Meta_run&amp;lt;/code&amp;gt; into your model in this fashion, it turns out to be better to define &amp;lt;code&amp;gt;Meta_run&amp;lt;/code&amp;gt; as a variable object, rather than as an index.  If you do that, then you can easily change its definition to a scalar, e.g.:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Meta_run := 0&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you aren't performing this meta-analysis of sampling error.&lt;br /&gt;
&lt;br /&gt;
== Theoretical determination of Sample Size ==&lt;br /&gt;
&lt;br /&gt;
In many cases, you can also compute the &amp;quot;theoretical&amp;quot; sample size required with a little algebra.  This is detailed in the [[Selecting the Sample Size]] in the [[Analytica User Guide]].&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Run]]&lt;br /&gt;
* [[Sample]]&lt;br /&gt;
* [[Selecting the Sample Size]]&lt;br /&gt;
* [[ProbBands]]&lt;br /&gt;
* [[Uncertainty Setup dialog]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=SampleType&amp;diff=48523</id>
		<title>SampleType</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=SampleType&amp;diff=48523"/>
		<updated>2016-08-22T23:37:53Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:System Variables]]&lt;br /&gt;
&lt;br /&gt;
== SysVar SampleType ==&lt;br /&gt;
&lt;br /&gt;
Determines the sampling method used to generate samples from probability distributions. Possible values are:&lt;br /&gt;
:&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;: Median Latin Hypercube&lt;br /&gt;
:&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;: Random Latin Hypercube&lt;br /&gt;
:&amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;: Simple Monte Carlo&lt;br /&gt;
:&amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt;: biased Median Latin Hypercube (legacy)&lt;br /&gt;
:&amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;: biased Random latin Hypercube (legacy)&lt;br /&gt;
:&amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt;: Sobol, limiting polynomial order as appropriate for sample size ([[Analytica 4.6]] or higher)&lt;br /&gt;
:&amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;: Sobol, allow use of high order polynomials ([[Analytica 4.6]] or higher)&lt;br /&gt;
&lt;br /&gt;
== Setting the sample type ==&lt;br /&gt;
&lt;br /&gt;
In Analytica, you usually set the [[SampleType]] from the [[Uncertainty Settings]] dialog, by selecting '''More options''' on the '''Uncertainty Sample''' tab.&lt;br /&gt;
&lt;br /&gt;
:[[image:SampleType on UncertaintySetup.png]]&lt;br /&gt;
&lt;br /&gt;
The dialog gives you access to options &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; only. To select options &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; thru &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;, you need to set the system variable from the [[Typescript Window]].&lt;br /&gt;
&lt;br /&gt;
== Latin Hypercube ==&lt;br /&gt;
&lt;br /&gt;
''Latin hypercube methods'' generate a sample of size ''N'' for a scalar uncertainty by selecting one sample from each &amp;lt;code&amp;gt;[(i - 1)/N, i/N]&amp;lt;/code&amp;gt;-fractile interval, ''i = 1..N''.&lt;br /&gt;
For example, with a sample size of 5, Latin Hypercube would ensure that one point is in the 0 to 20th percentile range, another point between the 20th to 40th percentiles, one between the 40th to 60th percentiles, one between the 60th to 80th percentiles and in the 80th to 100th percentile range. This helps to ensure that the full range of values gets coverage an avoid random clumping that can occur with pure Monte Carlo.  The points within the sample are randomly shuffled for each scalar uncertainty. &lt;br /&gt;
&lt;br /&gt;
''Median Latin Hypercube'' (MLH) selects the median percentile from each percentile range. This ensures maximal spreading of the sample points, but it also means that the set of samples is deterministic -- you'll always get the same points in the sample. The order of the points along the [[Run]] index is random, since the points are shuffled, so the sample itself (taking ordering into account) does indeed have a random component.&lt;br /&gt;
&lt;br /&gt;
''Random Latin Hypercube'' (RLH) selects the point in each percentile range at random. &lt;br /&gt;
&lt;br /&gt;
Latin Hypercube methods ensure spreading of the sample points within each individual scalar dimension, but there is no coordination between separate scalar uncertainties. Hence, in a 2-D sample space, clumping and areas with minimal coverage are still possible. Latin Hypercube methods converge quadratically faster than pure Month Carlo for smooth (analytic) problems involving a single uncertainty. No theoretical guarantees exist when multiple scalar uncertainties are involved, but measurably better convergence is often observed in real-life models with as many as 40 scalar uncertainties (see [http://blog.lumina.com/2014/latin-hypercube-vs-monte-carlo-sampling/ Latin Hypercube vs. Monte Carlo sampling]). With a large number of scalar uncertainties, convergence rates are not substantially better than Monte Carlo. &lt;br /&gt;
&lt;br /&gt;
In non-smooth models, Latin Hypercube methods can on rare occasions produce artifacts that slow convergence to be worse that Monte Carlo. These situations are rare.&lt;br /&gt;
&lt;br /&gt;
== Monte Carlo ==&lt;br /&gt;
&lt;br /&gt;
Pure Monte Carlo samples every point independently. It is a classical method in statistics, for which much is known. It lends itself to proof of many theoretical properties. Sampling error decreases as &amp;lt;math&amp;gt;1/\sqrt{N}&amp;lt;/math&amp;gt;, so that to halve the sampling error, you need to quadruple the sample size.&lt;br /&gt;
&lt;br /&gt;
== Biased Latin Hypercube ==&lt;br /&gt;
&lt;br /&gt;
Options &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; exist only to reproduce the same samples returned in Analytica 4.2 and earlier, but should not be used otherwise.&lt;br /&gt;
&lt;br /&gt;
In these earlier versions of Analytica, there was a very small bias in the shuffling algorithm.&lt;br /&gt;
&lt;br /&gt;
== Sobol sequences ==&lt;br /&gt;
&lt;br /&gt;
[[SobolSequence|Sobol sequences]] are a ''quasi-Monte Carlo'' method that attempt to distribute points evenly in the multi-dimensional sample space of multiple scalar uncertainties. These can be seen as a generalization of Latin Hypercube methods, but where Latin Hypercube methods treat each scalar uncertainty separately, Sobol sequences ensure that the points are (eventually) spread evenly within the multidimensional sample space.&lt;br /&gt;
&lt;br /&gt;
Sobol sequences also come with theoretical guarantees that hold even in (analytic) models involving multiple scalar uncertainties. Sampling error converges as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;O( (\log N)^d / N )&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where d is the number of scalar uncertainties and «N» is the sample size. As «N» gets immensely large, the denominator dominates the numerator, bringing this close to the holy grail of &amp;lt;math&amp;gt;O(1/N)&amp;lt;/math&amp;gt; -- which would be quadratically faster than Monte Carlo. However, when «d» is large, as it usually is, the numerator in this theoretical result is huge, and indeed the improved performance is often not evident until sample sizes approach astronomical sizes. &lt;br /&gt;
&lt;br /&gt;
Many publications claim to have created superior algorithms (to previous sampling methods) by employing Sobol sampling. My own experiments have not shown it to be substantially better than Latin Hypercube, and sometimes notably worse as realistic sample sizes (i.e., sample sizes under 1 million). &lt;br /&gt;
&lt;br /&gt;
There are two Sobol methods provided. Option &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; is the better of the two. It limits the highest order Sobol polynomial based on sample size. This also limits the number of scalar uncertainties that are &amp;quot;coordinated&amp;quot; before it starts over again with low-order polynomials. Option &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt; does not limit the polynomial order, allowing up to 21,000 scalar Sobol dimensions simultaneously before starting over again with the low-order polynomials. With option &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt; many artifacts occur in which points do not get even spread through the high-dimensional space, and obvious sections of the space go unexplored. These artifacts would disappear with enough sample points -- method &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; excludes the high-order Sobol polynomials that don't have a sample size large enough to support them, making it work much better.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Monte Carlo and probabilistic simulation]]&lt;br /&gt;
* [[Monte_Carlo_and_probabilistic_simulation#Monte_Carlo_sampling|Monte Carlo sampling]]&lt;br /&gt;
* [[SampleSize]]&lt;br /&gt;
* [[Sample]]&lt;br /&gt;
* [[Run]]&lt;br /&gt;
* [[System variables]]&lt;br /&gt;
* [[SobolSequence]]&lt;br /&gt;
* [[Distribution Densities Library]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=SampleType&amp;diff=48522</id>
		<title>SampleType</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=SampleType&amp;diff=48522"/>
		<updated>2016-08-22T23:37:00Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:System Variables]]&lt;br /&gt;
&lt;br /&gt;
== SysVar SampleType ==&lt;br /&gt;
&lt;br /&gt;
Determines the sampling method used to generate samples from probability distributions. Possible values are:&lt;br /&gt;
:&amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;: Median Latin Hypercube&lt;br /&gt;
:&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;: Random Latin Hypercube&lt;br /&gt;
:&amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;: Simple Monte Carlo&lt;br /&gt;
:&amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt;: biased Median Latin Hypercube (legacy)&lt;br /&gt;
:&amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;: biased Random latin Hypercube (legacy)&lt;br /&gt;
:&amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt;: Sobol, limiting polynomial order as appropriate for sample size ([[Analytica 4.6]] or higher)&lt;br /&gt;
:&amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;: Sobol, allow use of high order polynomials ([[Analytica 4.6]] or higher)&lt;br /&gt;
&lt;br /&gt;
== Setting the sample type ==&lt;br /&gt;
&lt;br /&gt;
In Analytica, you usually set the [[SampleType]] from the [[Uncertainty Settings]] dialog, by selecting '''More options''' on the '''Uncertainty Sample''' tab.&lt;br /&gt;
&lt;br /&gt;
:[[image:SampleType on UncertaintySetup.png]]&lt;br /&gt;
&lt;br /&gt;
The dialog gives you access to options &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; only. To select options &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; thru &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt;, you need to set the system variable from the [[Typescript Window]].&lt;br /&gt;
&lt;br /&gt;
== Latin Hypercube ==&lt;br /&gt;
&lt;br /&gt;
''Latin hypercube methods'' generate a sample of size ''N'' for a scalar uncertainty by selecting one sample from each &amp;lt;code&amp;gt;[(i - 1)/N, i/N]&amp;lt;/code&amp;gt;-fractile interval, ''i = 1..N''.&lt;br /&gt;
For example, with a sample size of 5, Latin Hypercube would ensure that one point is in the 0 to 20th percentile range, another point between the 20th to 40th percentiles, one between the 40th to 60th percentiles, one between the 60th to 80th percentiles and in the 80th to 100th percentile range. This helps to ensure that the full range of values gets coverage an avoid random clumping that can occur with pure Monte Carlo.  The points within the sample are randomly shuffled for each scalar uncertainty. &lt;br /&gt;
&lt;br /&gt;
''Median Latin Hypercube'' (MLH) selects the median percentile from each percentile range. This ensures maximal spreading of the sample points, but it also means that the set of samples is deterministic -- you'll always get the same points in the sample. The order of the points along the [[Run]] index is random, since the points are shuffled, so the sample itself (taking ordering into account) does indeed have a random component.&lt;br /&gt;
&lt;br /&gt;
''Random Latin Hypercube'' (RLH) selects the point in each percentile range at random. &lt;br /&gt;
&lt;br /&gt;
Latin Hypercube methods ensure spreading of the sample points within each individual scalar dimension, but there is no coordination between separate scalar uncertainties. Hence, in a 2-D sample space, clumping and areas with minimal coverage are still possible. Latin Hypercube methods converge quadratically faster than pure Month Carlo for smooth (analytic) problems involving a single uncertainty. No theoretical guarantees exist when multiple scalar uncertainties are involved, but measurably better convergence is often observed in real-life models with as many as 40 scalar uncertainties (see [http://blog.lumina.com/2014/latin-hypercube-vs-monte-carlo-sampling/ Latin Hypercube vs. Monte Carlo sampling]). With a large number of scalar uncertainties, convergence rates are not substantially better than Monte Carlo. &lt;br /&gt;
&lt;br /&gt;
In non-smooth models, Latin Hypercube methods can on rare occasions produce artifacts that slow convergence to be worse that Monte Carlo. These situations are rare.&lt;br /&gt;
&lt;br /&gt;
== Monte Carlo ==&lt;br /&gt;
&lt;br /&gt;
Pure Monte Carlo samples every point independently. It is a classical method in statistics, for which much is known. It lends itself to proof of many theoretical properties. Sampling error decreases as &amp;lt;math&amp;gt;1/\sqrt{N}&amp;lt;/math&amp;gt;, so that to halve the sampling error, you need to quadruple the sample size.&lt;br /&gt;
&lt;br /&gt;
== Biased Latin Hypercube ==&lt;br /&gt;
&lt;br /&gt;
Options &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; exist only to reproduce the same samples returned in Analytica 4.2 and earlier, but should not be used otherwise.&lt;br /&gt;
&lt;br /&gt;
In these earlier versions of Analytica, there was a very small bias in the shuffling algorithm.&lt;br /&gt;
&lt;br /&gt;
== Sobol sequences ==&lt;br /&gt;
&lt;br /&gt;
[[SobolSequence|Sobol sequences]] are a ''quasi-Monte Carlo'' method that attempt to distribute points evenly in the multi-dimensional sample space of multiple scalar uncertainties. These can be seen as a generalization of Latin Hypercube methods, but where Latin Hypercube methods treat each scalar uncertainty separately, Sobol sequences ensure that the points are (eventually) spread evenly within the multidimensional sample space.&lt;br /&gt;
&lt;br /&gt;
Sobol sequences also come with theoretical guarantees that hold even in (analytic) models involving multiple scalar uncertainties. Sampling error converges as &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;O( (\log N)^d / N )&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where d is the number of scalar uncertainties and «N» is the sample size. As «N» gets immensely large, the denominator dominates the numerator, bringing this close to the holy grail of &amp;lt;math&amp;gt;O(1/N)&amp;lt;/math&amp;gt; -- which would be quadratically faster than Monte Carlo. However, when «d» is large, as it usually is, the numerator in this theoretical result is huge, and indeed the improved performance is often not evident until sample sizes approach astronomical sizes. &lt;br /&gt;
&lt;br /&gt;
Many publications claim to have created superior algorithms (to previous sampling methods) by employing Sobol sampling. My own experiments have not shown it to be substantially better than Latin Hypercube, and sometimes notably worse as realistic sample sizes (i.e., sample sizes under 1 million). &lt;br /&gt;
&lt;br /&gt;
There are two Sobol methods provided. Option &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; is the better of the two. It limits the highest order Sobol polynomial based on sample size. This also limits the number of scalar uncertainties that are &amp;quot;coordinated&amp;quot; before it starts over again with low-order polynomials. Option &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt; does not limit the polynomial order, allowing up to 21,000 scalar Sobol dimensions simultaneously before starting over again with the low-order polynomials. With option &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt; many artifacts occur in which points do not get even spread through the high-dimensional space, and obvious sections of the space go unexplored. These artifacts would disappear with enough sample points -- method &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; excludes the high-order Sobol polynomials that don't have a sample size large enough to support them, making it work much better.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Monte_Carlo_and_probabilistic_simulation#Monte_Carlo_sampling|Monte Carlo sampling]]&lt;br /&gt;
* [[SampleSize]]&lt;br /&gt;
* [[Sample]]&lt;br /&gt;
* [[Run]]&lt;br /&gt;
* [[System variables]]&lt;br /&gt;
* [[SobolSequence]]&lt;br /&gt;
* [[Distribution Densities Library]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Selecting_the_Sample_Size&amp;diff=48521</id>
		<title>Selecting the Sample Size</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Selecting_the_Sample_Size&amp;diff=48521"/>
		<updated>2016-08-22T23:36:01Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt; Analytica User Guide &amp;gt; Expressing Uncertainty &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each probabilistic value is simulated by computing a random sample of values from the actual probability distribution.&lt;br /&gt;
&lt;br /&gt;
You can control the sampling method and sample size by using [[Uncertainty Setup dialog|Uncertainty Setup]]. The sections below discuss how to select a sample size.  &lt;br /&gt;
&lt;br /&gt;
==Choosing an Appropriate Sample Size==&lt;br /&gt;
&lt;br /&gt;
There is a clear trade-off for using a larger sample size in calculating an uncertainty variable. When you set the sample size to a large value, the result is less noisy, but it takes a longer time to compute the distribution. For an initial probabilistic calculation, a sample size of 20 to 50 is usually adequate.&lt;br /&gt;
&lt;br /&gt;
How should you choose the sample size «m»? It depends both on the cost of each model run, and what you want the results for. An advantage of the [[Monte Carlo]] method is that you can apply many standard statistical techniques to estimate the precision of estimates of the output distribution. This is because the generated sample of values for each output variable is a random sample from the true probability distribution for that variable.&lt;br /&gt;
&lt;br /&gt;
==Uncertainty about the Mean==&lt;br /&gt;
&lt;br /&gt;
First, suppose you are primarily interested in the precision of the [[mean]] of your output variable «y». Assume you have a random sample of «m» output values generated by [[Monte Carlo]] simulation:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(y_1, y_2, y_3, …y_m) &amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(1)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can estimate the mean and standard deviation of «y» using the following equations:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\vec y=\sum_{i=1}^m \frac { y_i }m&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(2)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;s^2=\sum_{i=1}^m \frac { (y_i - \vec y)^2} {m - 1}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(3)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This leads to the following confidence interval with confidence «α», where «c» is the deviation for the unit normally enclosing probability «α»:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\left (\vec y-c\frac {s} {\sqrt m}, \vec y + c\frac {s} {\sqrt m}\right ) &amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(4)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suppose you wish to obtain an estimate of the mean of «y» with an «α» confidence interval smaller than «w» units wide. What sample size do you need? You need to make sure that:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;w&amp;gt;2c \frac {s}{\sqrt m}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(5)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, rearranging the inequality:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m&amp;gt; \left ( \frac {2cs}{w}\right ) ^2&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(6)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To use this, first make a small Monte Carlo run with, say, 10 values to get an initial estimate of the variance of «y» — that is, «s2». You can then use equation (6) to estimate how many samples reduce the confidence interval to the requisite width «w».&lt;br /&gt;
&lt;br /&gt;
For example, suppose you wish to obtain a 95% confidence interval for the mean that is less than 20 units wide. Suppose your initial sample of 10 gives ''s = 40''. The deviation «c» enclosing a probability of 95% for a unit normal is about 2. Substituting these numbers into equation (6), you get:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m&amp;gt; \left ( \frac {2 \times 2 \times 40}{20} \right )^2 = 8^2 = 64&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(7)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, to get the required precision for the mean, you should set the sample size to about 64.&lt;br /&gt;
&lt;br /&gt;
== Estimating Confidence Intervals for Fractiles ==&lt;br /&gt;
&lt;br /&gt;
Another criterion for selecting sample size is the precision of the estimate of the median and other fractiles, or more generally, the precision of the estimated cumulative distribution. Assume that the sample «m» values of «y» are relabeled so that they are in increasing order:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt; y_1 \le, y_2 \le, ...y_m&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
«c» is the deviation enclosing probability «α» of the unit normal. Then the following pair of sample values constitutes the confidence interval:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;(y_i, y_k)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = \left \lfloor mp - c \sqrt {mp (1-p)} \right \rfloor&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(8)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = \left \lceil mp - c \sqrt {mp (1-p)} \right \rceil&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(9)&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Tip Title=&amp;quot;Note&amp;quot;&amp;gt; The brackets in equations (8) and (9) above mean round up [[File:lceil.png]] and round down[[File:rfloor.png]], since they are computing numbers that need to be integers.&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suppose you want to achieve sufficient precision such that the «a» confidence interval for the pth fractile «Y&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;» is given by (y&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, y&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;), where «y&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;» is an estimate of '''&amp;lt;math&amp;gt;{Y_p-{_\Delta}{_p}}&amp;lt;/math&amp;gt;''', and «y&amp;lt;sub&amp;gt;k&amp;lt;/sub&amp;gt;» is an estimate of '''&amp;lt;math&amp;gt;{Y_p+{_\Delta}{_p}}&amp;lt;/math&amp;gt;'''. In other words, you want «&amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;» confidence of «Y&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;» being between the sample values used as estimates of the (&amp;lt;math&amp;gt;p-{_\Delta}{_p})&amp;lt;/math&amp;gt;) and (&amp;lt;math&amp;gt;p+{_\Delta}{_p})&amp;lt;/math&amp;gt;) fractiles. What sample size do you need? Ignoring the rounding, you have approximately:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;i = m(p-{\Delta}p), k = m(p+{\Delta} p)&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(10)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;k - i = 2m{\Delta}p&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(11)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From equations (8) and (9) above, you have:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;k - i = 2c\sqrt {mp(1-p)}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(12)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equating the two expressions for ''k - 1'' , you obtain:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;2mp\Delta p = 2c \sqrt {mp(1-p)}&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(13)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m=p(1- p) \left (\frac {c}{\Delta p} \right )^2&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(14)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, suppose you want to be 95% confident that the estimated fractile Y&amp;lt;sub&amp;gt;.90&amp;lt;/sub&amp;gt; is between the estimated fractiles Y&amp;lt;sub&amp;gt;.85&amp;lt;/sub&amp;gt; and Y&amp;lt;sub&amp;gt;.95&amp;lt;/sub&amp;gt;. So you have &amp;lt;math&amp;gt;\Delta p&amp;lt;/math&amp;gt; = 0.05, and ''c ≈ 2''. Substituting the numbers into equation (14), you get:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m = 0.90 \times  (1 - 0.90) \times \left (\frac {2}{0.05} \right )^2 = 144&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(15)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
On the other hand, suppose you want the credible interval for the least precise estimated percentile (the 50th percentile) to have a 95% confidence interval of plus or minus one estimated percentile. Then:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;m = 0.5 \times  (1 - 0.5) \times \left (\frac {2}{0.01} \right )^2 = 10,000&amp;lt;/math&amp;gt;&amp;lt;div class=&amp;quot;floatright&amp;quot;&amp;gt;(16)&amp;lt;/div&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These results are completely independent of the shape of the distribution. If you find this an appropriate way to state your requirements for the precision of the estimated distribution, you can determine the sample size before doing ''any'' runs to see what sort of distribution it might be.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[SampleSize]]&lt;br /&gt;
* [[SampleType]]&lt;br /&gt;
* [[Sample]]&lt;br /&gt;
* [[Monte_Carlo_and_probabilistic_simulation#Monte_Carlo_sampling|Monte Carlo sampling]]&lt;br /&gt;
* [[Evaluation Modes]]&lt;br /&gt;
* [[Uncertainty Setup dialog]]&lt;br /&gt;
* [[Distribution Densities Library]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Uncertainty views / {{PAGENAME}} / Choosing an appropriate distribution&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Uncertainty_Setup_dialog&amp;diff=48520</id>
		<title>Uncertainty Setup dialog</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Uncertainty_Setup_dialog&amp;diff=48520"/>
		<updated>2016-08-22T23:33:16Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
[[Category: Windows and dialogs]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressing Uncertainty &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
___TOC___&lt;br /&gt;
Use the '''Uncertainty Setup''' dialog to inspect and change options to compute and display uncertain quantities. It contains five tabs/menu options: '''Uncertainty sample''' including sampling method, '''Statistics''', '''Probability bands''', '''Cumulative probability''' and '''Probability density''' views. Each is described below.  The Uncertainty sample methods apply to the entire model. You can apply the rest to a single variable or as the default for the entire model. It saves all settings with your model.&lt;br /&gt;
&lt;br /&gt;
To open the '''Uncertainty Setup''' dialog, select '''Uncertainty Options''' from the [[Result menu]] or ''Control+u''. To set values for a specific variable, select the variable before opening the dialog.&lt;br /&gt;
&lt;br /&gt;
You can select each of the five options in the '''Uncertainty Setup''' dialog from the '''Analysis option''' menu.&lt;br /&gt;
:[[File:Analysis option.png]]&lt;br /&gt;
&lt;br /&gt;
== Uncertainty sample==&lt;br /&gt;
&lt;br /&gt;
''For pre-[[Analytica 5.0]] releases, please see [[Uncertainty_Setup_dialog/Uncertainty sample/4.6]].''&lt;br /&gt;
	&lt;br /&gt;
:[[File:Uncertainty setup.png]]&lt;br /&gt;
&lt;br /&gt;
'''Sample size''': This number specifies how many runs or iterations Analytica performs to estimate probability distributions. Larger sample sizes take more time and memory to compute, and produce smoother distributions and more precise statistics. See [[Selecting the Sample Size]] for guidelines on selecting a sample size. In the [[Analytica Free 101|Free 101]] and [[Editions of Analytica|Professional editions]], the sample size must be between 2 and 32,000. You can access this number in expressions in your models as the system variable ''[[SampleSize]]''.&lt;br /&gt;
	&lt;br /&gt;
=== Sampling method ===&lt;br /&gt;
&lt;br /&gt;
The sampling method is used to determine how to generate a random sample of the specified sample size, '''m''', for each uncertain quantity. Analytica offers four options: '''Median Latin hypercube''' (the default), '''Random Latin hypercube''', '''Monte Carlo''', and '''Sobol''' sampling methods. See [[Monte Carlo and probabilistic simulation]] for details.&lt;br /&gt;
	&lt;br /&gt;
=== Random seed ===&lt;br /&gt;
	&lt;br /&gt;
This value must be a number between 0 and 100,000,000 (10&amp;lt;sup&amp;gt;8&amp;lt;/sup&amp;gt;). The series of random numbers starts from this seed value when:&lt;br /&gt;
	&lt;br /&gt;
* A model is opened.&lt;br /&gt;
* The value in this field is changed.&lt;br /&gt;
* You check the Reset once box, and close the Uncertainty Setup dialog by clicking '''Accept''' or '''Set Default'''.&lt;br /&gt;
	&lt;br /&gt;
=== Reset once ===&lt;br /&gt;
&lt;br /&gt;
Check the ''Reset once'' box to produce the exact same series of random numbers.&lt;br /&gt;
&lt;br /&gt;
== Statistics option ==&lt;br /&gt;
&lt;br /&gt;
To change the statistics reported when you select '''Statistics''' as the [[uncertainty view of a result]], select the '''Statistics''' option from the '''Analysis option''' popup menu.&lt;br /&gt;
	&lt;br /&gt;
:[[File:Statistic option.png]]&lt;br /&gt;
&lt;br /&gt;
==Probability Bands option ==&lt;br /&gt;
To change the probability bands displayed when you select '''Probability Bands''' as the uncertainty view for a result, select the '''Probability Bands''' option from the '''Analysis option''' popup menu.&lt;br /&gt;
&lt;br /&gt;
:[[File:Probability band.png]]&lt;br /&gt;
&lt;br /&gt;
== Probability density option ==&lt;br /&gt;
&lt;br /&gt;
To change how probability density is estimated and drawn, select '''Probability Density''' from the '''Analysis option''' popup menu.&lt;br /&gt;
&lt;br /&gt;
:[[File:Probability density.png]]&lt;br /&gt;
&lt;br /&gt;
Analytica estimates the probability density function, like other uncertainty views, from the underlying array of sample values for each uncertain quantity. The probability density is highly susceptible to random sampling variation and noise. Both histogramming and kernel density smoothing techniques are available for estimating the probability density from the sample, but to ultimately reduce noise and variability it may be necessary to increase sample size (for details on selecting the sample size, see [[Selecting the Sample Size]]). The following example graphs compare the two methods on the same uncertain result:&lt;br /&gt;
&lt;br /&gt;
:[[File:Histogram.png]]&lt;br /&gt;
&lt;br /&gt;
'''Histogram''': The histogram estimation methods partition the space of possible continuous values into bins, and then tally how many samples land in each bin. The probability density is then equal to the fraction of the Monte Carlo sample landing in a given bin divided by the bin’s width. The average number of points landing in each bin determines both the smoothness of the resulting function and the resolution of the resulting plot. With more bins, a finer resolution is obtained, but since fewer points land in each bin, the amount of random fluctuation increases resulting in a noisier plot. '''The Samples per PDF step interval''' setting sizes the bin width to match the average number of points per bin.&lt;br /&gt;
With larger sample sizes, you can increase the '''Samples per PDF step interval''' to achieve smoother plots, since more samples will land in each bin. A number approximately equal to the square root of sample size tends to work fairly well.&lt;br /&gt;
&lt;br /&gt;
You can also control how the partitioning of the space of values is performed. When '''Equal X axis steps''' is used, the range of values from the smallest to largest sample point is partitioned into equal sized bins. With this method, all bins have the same width, but the number of points falling in each bin varies. When '''Equal weighted probability steps''' is used, the bins are sized so that each bin contains approximately the same fraction of the total probability. With this method, the fraction of the sample in each bin is nearly constant, but the width of each bin varies. When '''Equal sample probability steps''' is used, the bins are partitioned so that the number of sample points in each bin is constant, with the width of each bin again varying. '''Equal weighted probability steps''' and '''Equal sample probability steps''' are exactly equivalent when standard equally-weighted Monte Carlo or Latin Hypercube sampling is being used. They differ when the Sample Weighting system variable assigns different weights to each sample along the Run index, as is sometimes employed with importance sampling, logic sampling for posterior analysis, and rare-event modeling. See [[Importance weights|Importance weighting]].&lt;br /&gt;
&lt;br /&gt;
Probability density plots using the histogram method default to the '''Step''' chart type, which emphasizes the histogram and reveals the bin placements. When desired, this can be changed to the standard line style from the '''Graph Setup''', see [[Graph setup dialog|Chart Type tab]].&lt;br /&gt;
&lt;br /&gt;
'''Smoothing''': The smoothing method estimates probability density using a technique known as Kernel Density Estimation (KDE) or [[Kernel Density Smoothing]]. This technique replaces each Monte Carlo sample with a [[Gaussian]] curve, called a Kernel, and then sums the curve to obtain the final continuous curve. Unlike a histogram, the degree of smoothness and the resolution of the plot are independent. The '''Smoothing factor''' controls the smoothness or amount of detail in the estimated PDF. The more info button next to the '''Smoothing''' radio control jumps to a page on the Analytica Wiki that elaborates in more detail on how kernel density smoothing works.&lt;br /&gt;
&lt;br /&gt;
Due to the randomness of Monte Carlo sampling, estimations of probability density are often quite noisy. The '''Smoothing''' method can often provide smoother and more intuitively appealing plots than '''Histogram''' methods, but the averaging effects inherent in '''smoothing''' can also introduce some minor artifacts. In particular, Smoothing tends to increase the apparent variance in your result slightly, with a greater increase when the '''Smoothing''' factor is greater. This increase in variance is also seen as a decrease in the height of peaks. Sharp cutoffs (such as is the case with a [[Uniform]] distribution, for example) become rounded with a decaying tail past the cutoff point. And when positive-only distributions begin with a very sharp rise, the density estimate may get smoothed into a plot with a tail extending into the negative value territory.&lt;br /&gt;
	&lt;br /&gt;
== Cumulative probability option ==&lt;br /&gt;
To change how the cumulative probability values are drawn or to change their resolution, select the respective option from the '''Analysis option''' popup menu.&lt;br /&gt;
	&lt;br /&gt;
:[[File:Cumulative probability.png]]&lt;br /&gt;
&lt;br /&gt;
Analytica estimates the cumulative distribution function, like other uncertainty views, from the underlying array of sample values for each uncertain quantity. As with any simulation-based method, each estimated distribution has some noise and variability from one evaluation to the next. Cumulative probability estimates are less susceptible to noise than, for example, probability density estimates.&lt;br /&gt;
&lt;br /&gt;
The '''Samples per CDF plot''' '''point''' setting controls the average number of sample values used to estimate each point on the cumulative distribution function ([[CDF]]) curve, which ultimately controls the number of points plotted on your result.&lt;br /&gt;
&lt;br /&gt;
The '''Equal X axis steps, Equal weighted probability steps''' and '''Equal sample probability steps''' control which points are used in plot of the cumulative probability. '''Equal X axis steps''' spaces points equally along the X axis. '''Equal weighted probability steps''' uses the sample to estimate a set of &amp;lt;code&amp;gt;m+!&amp;lt;/code&amp;gt; fractiles (quantiles), &amp;lt;code&amp;gt;Xp&amp;lt;/code&amp;gt;, at equal probability intervals, where &amp;lt;code&amp;gt;p=0, q, 2q, ... 1, &amp;lt;/code&amp;gt;and&amp;lt;code&amp;gt; q = 1/m&amp;lt;/code&amp;gt;. The cumulative probability is plotted at each of the points &amp;lt;code&amp;gt;Xp&amp;lt;/code&amp;gt;, increasing in equal steps along the vertical axis. Points are plotted closer together along the horizontal axis in the regions where the density is the greatest. '''Equal sample probability steps''' plots one point each at each nth sample point, where n is the sample per CDF plot point, ignoring the weight on each sample point when they are weighted differently. The cumulative probability up to the nth point is estimated and plotted. Equal weighted probability steps and '''Equal sample probability steps''' are exactly equivalent unless unequal sample weighting is employed (see [[Importance weights]]).&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
The '''Uncertainty Sample''' pane was reworked in [[Analytica 5.0]]. Prior to 5.0, an option for changing the pseudo-random generator method was shown. This was removed (if you really want to use a different random generator algorithm, you can still change this by changing the [[RandomType]] system variable). &lt;br /&gt;
&lt;br /&gt;
The [[Kernel Density Smoothing]] option for probability density estimation was introduced in [[Analytica 4.4]].&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Expressing Uncertainty]]&lt;br /&gt;
* [[Tutorial: Open a model to browse#Displaying_alternative_uncertain_views|Tutorial: Displaying alternative uncertain views]]&lt;br /&gt;
* [[CDF]]&lt;br /&gt;
* [[Gaussian]]&lt;br /&gt;
* [[Probability distributions]]&lt;br /&gt;
* [[Distribution Densities Library]]&lt;br /&gt;
* [[Kernel Density Smoothing]]&lt;br /&gt;
* [[Importance weights]]&lt;br /&gt;
* [[Selecting the Sample Size]]&lt;br /&gt;
* [[SampleSize]]&lt;br /&gt;
* [[SampleType]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Expressing Uncertainty / {{PAGENAME}} / Uncertainty views&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Uncertainty_Setup_dialog&amp;diff=48519</id>
		<title>Uncertainty Setup dialog</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Uncertainty_Setup_dialog&amp;diff=48519"/>
		<updated>2016-08-22T23:30:34Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
[[Category: Windows and dialogs]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressing Uncertainty &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
___TOC___&lt;br /&gt;
Use the '''Uncertainty Setup''' dialog to inspect and change options to compute and display uncertain quantities. It contains five tabs/menu options: '''Uncertainty sample''' including sampling method, '''Statistics''', '''Probability bands''', '''Cumulative probability''' and '''Probability density''' views. Each is described below.  The Uncertainty sample methods apply to the entire model. You can apply the rest to a single variable or as the default for the entire model. It saves all settings with your model.&lt;br /&gt;
&lt;br /&gt;
To open the '''Uncertainty Setup''' dialog, select '''Uncertainty Options''' from the [[Result menu]] or ''Control+u''. To set values for a specific variable, select the variable before opening the dialog.&lt;br /&gt;
&lt;br /&gt;
You can select each of the five options in the '''Uncertainty Setup''' dialog from the '''Analysis option''' menu.&lt;br /&gt;
:[[File:Analysis option.png]]&lt;br /&gt;
&lt;br /&gt;
== Uncertainty sample==&lt;br /&gt;
&lt;br /&gt;
''For pre-[[Analytica 5.0]] releases, please see [[Uncertainty_Setup_dialog/Uncertainty sample/4.6]].''&lt;br /&gt;
	&lt;br /&gt;
:[[File:Uncertainty setup.png]]&lt;br /&gt;
&lt;br /&gt;
'''Sample size''': This number specifies how many runs or iterations Analytica performs to estimate probability distributions. Larger sample sizes take more time and memory to compute, and produce smoother distributions and more precise statistics. See [[Selecting the Sample Size]] for guidelines on selecting a sample size. In the [[Analytica Free 101|Free 101]] and [[Editions of Analytica|Professional editions]], the sample size must be between 2 and 32,000. You can access this number in expressions in your models as the system variable ''[[SampleSize]]''.&lt;br /&gt;
	&lt;br /&gt;
=== Sampling method ===&lt;br /&gt;
&lt;br /&gt;
The sampling method is used to determine how to generate a random sample of the specified sample size, '''m''', for each uncertain quantity. Analytica offers four options: '''Median Latin hypercube''' (the default), '''Random Latin hypercube''', '''Monte Carlo''', and '''Sobol''' sampling methods. See [[Monte Carlo and probabilistic simulation]] for details.&lt;br /&gt;
	&lt;br /&gt;
=== Random seed ===&lt;br /&gt;
	&lt;br /&gt;
This value must be a number between 0 and 100,000,000 (10&amp;lt;sup&amp;gt;8&amp;lt;/sup&amp;gt;). The series of random numbers starts from this seed value when:&lt;br /&gt;
	&lt;br /&gt;
* A model is opened.&lt;br /&gt;
* The value in this field is changed.&lt;br /&gt;
* You check the Reset once box, and close the Uncertainty Setup dialog by clicking '''Accept''' or '''Set Default'''.&lt;br /&gt;
	&lt;br /&gt;
=== Reset once ===&lt;br /&gt;
&lt;br /&gt;
Check the ''Reset once'' box to produce the exact same series of random numbers.&lt;br /&gt;
&lt;br /&gt;
== Statistics option ==&lt;br /&gt;
&lt;br /&gt;
To change the statistics reported when you select '''Statistics''' as the [[uncertainty view of a result]], select the '''Statistics''' option from the '''Analysis option''' popup menu.&lt;br /&gt;
	&lt;br /&gt;
:[[File:Statistic option.png]]&lt;br /&gt;
&lt;br /&gt;
==Probability Bands option ==&lt;br /&gt;
To change the probability bands displayed when you select '''Probability Bands''' as the uncertainty view for a result, select the '''Probability Bands''' option from the '''Analysis option''' popup menu.&lt;br /&gt;
&lt;br /&gt;
:[[File:Probability band.png]]&lt;br /&gt;
&lt;br /&gt;
== Probability density option ==&lt;br /&gt;
&lt;br /&gt;
To change how probability density is estimated and drawn, select '''Probability Density''' from the '''Analysis option''' popup menu.&lt;br /&gt;
&lt;br /&gt;
:[[File:Probability density.png]]&lt;br /&gt;
&lt;br /&gt;
Analytica estimates the probability density function, like other uncertainty views, from the underlying array of sample values for each uncertain quantity. The probability density is highly susceptible to random sampling variation and noise. Both histogramming and kernel density smoothing techniques are available for estimating the probability density from the sample, but to ultimately reduce noise and variability it may be necessary to increase sample size (for details on selecting the sample size, see [[Selecting the Sample Size]]). The following example graphs compare the two methods on the same uncertain result:&lt;br /&gt;
&lt;br /&gt;
:[[File:Histogram.png]]&lt;br /&gt;
&lt;br /&gt;
'''Histogram''': The histogram estimation methods partition the space of possible continuous values into bins, and then tally how many samples land in each bin. The probability density is then equal to the fraction of the Monte Carlo sample landing in a given bin divided by the bin’s width. The average number of points landing in each bin determines both the smoothness of the resulting function and the resolution of the resulting plot. With more bins, a finer resolution is obtained, but since fewer points land in each bin, the amount of random fluctuation increases resulting in a noisier plot. '''The Samples per PDF step interval''' setting sizes the bin width to match the average number of points per bin.&lt;br /&gt;
With larger sample sizes, you can increase the '''Samples per PDF step interval''' to achieve smoother plots, since more samples will land in each bin. A number approximately equal to the square root of sample size tends to work fairly well.&lt;br /&gt;
&lt;br /&gt;
You can also control how the partitioning of the space of values is performed. When '''Equal X axis steps''' is used, the range of values from the smallest to largest sample point is partitioned into equal sized bins. With this method, all bins have the same width, but the number of points falling in each bin varies. When '''Equal weighted probability steps''' is used, the bins are sized so that each bin contains approximately the same fraction of the total probability. With this method, the fraction of the sample in each bin is nearly constant, but the width of each bin varies. When '''Equal sample probability steps''' is used, the bins are partitioned so that the number of sample points in each bin is constant, with the width of each bin again varying. '''Equal weighted probability steps''' and '''Equal sample probability steps''' are exactly equivalent when standard equally-weighted Monte Carlo or Latin Hypercube sampling is being used. They differ when the Sample Weighting system variable assigns different weights to each sample along the Run index, as is sometimes employed with importance sampling, logic sampling for posterior analysis, and rare-event modeling. See [[Importance weights|Importance weighting]].&lt;br /&gt;
&lt;br /&gt;
Probability density plots using the histogram method default to the '''Step''' chart type, which emphasizes the histogram and reveals the bin placements. When desired, this can be changed to the standard line style from the '''Graph Setup''', see [[Graph setup dialog|Chart Type tab]].&lt;br /&gt;
&lt;br /&gt;
'''Smoothing''': The smoothing method estimates probability density using a technique known as Kernel Density Estimation (KDE) or [[Kernel Density Smoothing]]. This technique replaces each Monte Carlo sample with a [[Gaussian]] curve, called a Kernel, and then sums the curve to obtain the final continuous curve. Unlike a histogram, the degree of smoothness and the resolution of the plot are independent. The '''Smoothing factor''' controls the smoothness or amount of detail in the estimated PDF. The more info button next to the '''Smoothing''' radio control jumps to a page on the Analytica Wiki that elaborates in more detail on how kernel density smoothing works.&lt;br /&gt;
&lt;br /&gt;
Due to the randomness of Monte Carlo sampling, estimations of probability density are often quite noisy. The '''Smoothing''' method can often provide smoother and more intuitively appealing plots than '''Histogram''' methods, but the averaging effects inherent in '''smoothing''' can also introduce some minor artifacts. In particular, Smoothing tends to increase the apparent variance in your result slightly, with a greater increase when the '''Smoothing''' factor is greater. This increase in variance is also seen as a decrease in the height of peaks. Sharp cutoffs (such as is the case with a [[Uniform]] distribution, for example) become rounded with a decaying tail past the cutoff point. And when positive-only distributions begin with a very sharp rise, the density estimate may get smoothed into a plot with a tail extending into the negative value territory.&lt;br /&gt;
	&lt;br /&gt;
== Cumulative probability option ==&lt;br /&gt;
To change how the cumulative probability values are drawn or to change their resolution, select the respective option from the '''Analysis option''' popup menu.&lt;br /&gt;
	&lt;br /&gt;
:[[File:Cumulative probability.png]]&lt;br /&gt;
&lt;br /&gt;
Analytica estimates the cumulative distribution function, like other uncertainty views, from the underlying array of sample values for each uncertain quantity. As with any simulation-based method, each estimated distribution has some noise and variability from one evaluation to the next. Cumulative probability estimates are less susceptible to noise than, for example, probability density estimates.&lt;br /&gt;
&lt;br /&gt;
The '''Samples per CDF plot''' '''point''' setting controls the average number of sample values used to estimate each point on the cumulative distribution function ([[CDF]]) curve, which ultimately controls the number of points plotted on your result.&lt;br /&gt;
&lt;br /&gt;
The '''Equal X axis steps, Equal weighted probability steps''' and '''Equal sample probability steps''' control which points are used in plot of the cumulative probability. '''Equal X axis steps''' spaces points equally along the X axis. '''Equal weighted probability steps''' uses the sample to estimate a set of &amp;lt;code&amp;gt;m+!&amp;lt;/code&amp;gt; fractiles (quantiles), &amp;lt;code&amp;gt;Xp&amp;lt;/code&amp;gt;, at equal probability intervals, where &amp;lt;code&amp;gt;p=0, q, 2q, ... 1, &amp;lt;/code&amp;gt;and&amp;lt;code&amp;gt; q = 1/m&amp;lt;/code&amp;gt;. The cumulative probability is plotted at each of the points &amp;lt;code&amp;gt;Xp&amp;lt;/code&amp;gt;, increasing in equal steps along the vertical axis. Points are plotted closer together along the horizontal axis in the regions where the density is the greatest. '''Equal sample probability steps''' plots one point each at each nth sample point, where n is the sample per CDF plot point, ignoring the weight on each sample point when they are weighted differently. The cumulative probability up to the nth point is estimated and plotted. Equal weighted probability steps and '''Equal sample probability steps''' are exactly equivalent unless unequal sample weighting is employed (see [[Importance weights]]).&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
&lt;br /&gt;
The '''Uncertainty Sample''' pane was reworked in [[Analytica 5.0]]. Prior to 5.0, an option for changing the pseudo-random generator method was shown. This was removed (if you really want to use a different random generator algorithm, you can still change this by changing the [[RandomType]] system variable). &lt;br /&gt;
&lt;br /&gt;
The [[Kernel Density Smoothing]] option for probability density estimation was introduced in [[Analytica 4.4]].&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Expressing Uncertainty]]&lt;br /&gt;
* [[Tutorial: Open a model to browse#Displaying_alternative_uncertain_views|Tutorial: Displaying alternative uncertain views]]&lt;br /&gt;
* [[CDF]]&lt;br /&gt;
* [[Gaussian]]&lt;br /&gt;
* [[Probability distributions]]&lt;br /&gt;
* [[Distribution Densities Library]]&lt;br /&gt;
* [[Kernel Density Smoothing]]&lt;br /&gt;
* [[Importance weights]]&lt;br /&gt;
* [[Selecting the Sample Size]]&lt;br /&gt;
* [[SampleSize]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Expressing Uncertainty / {{PAGENAME}} / Uncertainty views&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Dynamic_function&amp;diff=48518</id>
		<title>Dynamic function</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Dynamic_function&amp;diff=48518"/>
		<updated>2016-08-22T23:25:56Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Dynamic Simulation &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Dynamic(initial1, ''initial2..., initialn'', expr)==&lt;br /&gt;
Performs dynamic simulation, calculating the value of its defined variable at each element of [[Time]]. The result of [[Dynamic]]() is an array, indexed by [[Time]].&lt;br /&gt;
&lt;br /&gt;
«Initial1», ...«initialn» are the values of the variable for the first ''n'' time periods. «expr» is an expression giving the value of the variable for each subsequent time period. «expr» can refer to the variable in earlier time periods, that is, contain its own identifier in its definition. If variable &amp;lt;code&amp;gt;Var&amp;lt;/code&amp;gt; is defined using [[Dynamic]], «expr» can be a function of &amp;lt;code&amp;gt;Var[Time - k]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Self[Time - k]&amp;lt;/code&amp;gt;, where ''k'' is an expression that evaluates to an integer between ''1'' and ''t'', and ''t'' is the time step at which «expr» is being evaluated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title=&amp;quot;Tip&amp;quot;&amp;gt; &lt;br /&gt;
Square brackets ([ ]) are necessary around &amp;lt;code&amp;gt;Time - t&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[Dynamic]] function must appear at the topmost level of a definition. It cannot be used inside another expression.&lt;br /&gt;
&lt;br /&gt;
When a dynamic variable refers to itself, it appears in its own list of inputs and outputs, with a symbol for cyclic dependency:  [[File:Chapter17_1.5.png]].&lt;br /&gt;
&lt;br /&gt;
'''Library:''' Special&lt;br /&gt;
&lt;br /&gt;
'''When to use:''' Use [[Dynamic]]() for defining variables that are cyclically dependent. There are only two functions in Analytica that allow a cycle to be formed, in which a variable can refer to its own value or to other variables that depend on it. Those two functions are [[Dynamic]]() and [[Iterate]](). Only dynamic variables can compute their value based on the values at at earlier time periods.&lt;br /&gt;
&lt;br /&gt;
'''Example:''' [[Dynamic]]() can be used to calculate the effect of inflation on the price of gasoline in the years 1990 to 1994.&lt;br /&gt;
&lt;br /&gt;
If the initial value is $1.20 per gallon and the rate of inflation is 5% per year, then &amp;lt;code&amp;gt;Gasprice&amp;lt;/code&amp;gt; can be defined as: &amp;lt;code&amp;gt;Dynamic(1.2, Gasprice[Time - 1]*1.05)&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Dynamic(1.2, Self[Time - 1]*1.05)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
:[[File:Chapter17_2.png]]&lt;br /&gt;
&lt;br /&gt;
Clicking the '''Result''' button and viewing the mid value as a table displays the following results.&lt;br /&gt;
&lt;br /&gt;
:[[File:Chapter17_3.png]]&lt;br /&gt;
&lt;br /&gt;
For 1990, Analytica uses the initial value of &amp;lt;code&amp;gt;Gasprice (1.2)&amp;lt;/code&amp;gt;. For each subsequent year, Analytica multiplies the value of &amp;lt;code&amp;gt;Gasprice&amp;lt;/code&amp;gt; at &amp;lt;code&amp;gt;[Time - 1]&amp;lt;/code&amp;gt; by 1.05 (the 5 percent inflation rate).&lt;br /&gt;
&lt;br /&gt;
==x[Time - k]== &lt;br /&gt;
Given a variable &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; and brackets enclosing [[Time]] minus an integer «k», returns the value for «x», «k» time periods back from the current time period. This function is only valid for variables defined using the [[Dynamic]] function.&lt;br /&gt;
&lt;br /&gt;
'''Library:''' Special&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Tutorial: Dynamic system model]]&lt;br /&gt;
* [[Dynamic]]&lt;br /&gt;
* [[Time]]&lt;br /&gt;
* [[Time index]]&lt;br /&gt;
* [[Iterate]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Time index / {{PAGENAME}} / Time index details&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Time_index&amp;diff=48517</id>
		<title>Time index</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Time_index&amp;diff=48517"/>
		<updated>2016-08-22T23:24:27Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Dynamic Simulation &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dynamic simulation time periods are specified in the system variable [[Time]]. To perform dynamic simulation, you must provide a [[definition]] for '''Time'''.&lt;br /&gt;
&lt;br /&gt;
To edit the definition of [[Time]], select '''Edit Time''' from the [[Definition menu]] to open the [[Object window]] for '''Time'''.&lt;br /&gt;
&lt;br /&gt;
[[Time]] is defined by default as a list of three numbers 0, 1, and 2. You might want to define '''Time''' as a list of years, as in the following example.&lt;br /&gt;
&lt;br /&gt;
:[[File:Chapter17_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Time]] becomes the index for the array that results from the [[Dynamic]] function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip tilte=&amp;quot;Tip&amp;quot;&amp;gt; A model can have only one definition '''Time''' — that is, one set of time periods for Dynamic functions. Any number of variables in the model can be defined using [[Dynamic]]().&lt;br /&gt;
&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tip title= &amp;quot;Tip&amp;quot;&amp;gt;A variation, [[Dynamic]][T](), can be used to represent recurrences over indexes other than '''Time''', but placing the index name in square brackets. This provides a way to express secondary recurrences if you’ve already used your [[Time]] index for sometime else. The dynamic concepts are introduced thoroughly in this chapter using '''Time''', but if you have a loop using a different index, just substitute your other index for [[Time]] in what follows.&lt;br /&gt;
&amp;lt;/Tip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Arrays and indexes]]&lt;br /&gt;
* [[Time]]&lt;br /&gt;
* [[Dynamic]]&lt;br /&gt;
* [[Tutorial: Dynamic system model]]&lt;br /&gt;
* [[Date and time values]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Dynamic Simulation / {{PAGENAME}} / Dynamic function&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Dynamic_Simulation&amp;diff=48516</id>
		<title>Dynamic Simulation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Dynamic_Simulation&amp;diff=48516"/>
		<updated>2016-08-22T23:23:56Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This chapter shows you how to model changes over time. This can be done in Analytica by means of dynamic variables. A dynamic variable is a quantity that changes over time — for example, the effect of inflation on car prices over a ten-year period — with a recurrence or dependence on previous time periods. The term dynamic is used in this chapter to refer to  [[Dynamic]] function, an Analytica system function that together with the system variable [[Time]] enables to perform dynamic simulations. We recommend that you read the [[Arrays and Indexes]] chapter, before using these features.&lt;br /&gt;
&lt;br /&gt;
==Sections==&lt;br /&gt;
* [[Time index]]&lt;br /&gt;
* [[Dynamic function]]&lt;br /&gt;
* [[Time index details]]&lt;br /&gt;
* [[Dynamic initial values]]&lt;br /&gt;
* [[Dynamic using arrays]]&lt;br /&gt;
* [[Dynamic dependencies]]&lt;br /&gt;
* [[Dynamic and uncertainty]]&lt;br /&gt;
* [[Dynamic on non-Time Indexes]]&lt;br /&gt;
* [[Reverse Dynamic]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Tutorial: Dynamic system model]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Statistics, Sensitivity, and Uncertainty Analysis / {{PAGENAME}} / Integration with data and applications&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Time&amp;diff=48515</id>
		<title>Time</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Time&amp;diff=48515"/>
		<updated>2016-08-22T23:23:25Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:System Variables]]&lt;br /&gt;
&lt;br /&gt;
== SysVar Time ==&lt;br /&gt;
&lt;br /&gt;
[[Time]] is a built-in index available in Analytica.  You can get to this variable from the [[Definition menu]] (option '''Show Time''' from browse mode or '''Edit Time''' from [[toolbar|edit mode]]).&lt;br /&gt;
&lt;br /&gt;
The [[Time]] index behaves like any other Analytica index.  It can be used as a dimension for arrays and tables, referred to by identifier in expressions, and operated over in array functions. In addition, [[Time]] provides an extra functionality not available to other indexes -- its use with [[Dynamic]].&lt;br /&gt;
&lt;br /&gt;
[[Dynamic|Dynamic models]] compute the value of a variable from the values of itself or other variables at earlier points in [[Time]].  Dynamic loops between variables, creating cycles on the influence diagram, are then possible.  This ability to recur over the [[Time]] index is a very powerful feature of Analytica, and is something that is only possible over this special system index, [[Time]].&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Time index]]&lt;br /&gt;
* [[Time index details]]&lt;br /&gt;
* [[Module 5: Time as an Extrinsic index|Time as an Extrinsic index]]&lt;br /&gt;
* [[Defining the Time variable]]&lt;br /&gt;
* [[Tutorial: Dynamic system model]]&lt;br /&gt;
* [[Dynamic]]&lt;br /&gt;
* [[Dynamic Simulation]]&lt;br /&gt;
* [[:Category: System Variables]]&lt;br /&gt;
* [[IdentPred]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Dynamic&amp;diff=48514</id>
		<title>Dynamic</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Dynamic&amp;diff=48514"/>
		<updated>2016-08-22T23:22:51Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Evaluation Functions]]&lt;br /&gt;
[[category:Top level functions]]&lt;br /&gt;
[[Category:Doc Status D]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This page needs work.  A better introductory reference for now is the Analytica User Guide chapter [[Dynamic Simulation]]''.&lt;br /&gt;
&lt;br /&gt;
== Dynamic(initial1, ''initial2, ..., initialN'', expr) ==&lt;br /&gt;
&lt;br /&gt;
The dynamic function performs dynamic simulation, calculating its value at each element of [[Time]].  [[Time]] is a special system index that is built into Analytica, and is the only index that [[Dynamic]] can operate over in this fashion.  The result of [[Dynamic]] is an array indexed by the system index [[Time]].&lt;br /&gt;
&lt;br /&gt;
When the [[Dynamic]] function is used, it must appear as the topmost function in the definition.  It can contain one or more initial value parameters, containing the values at &amp;lt;code&amp;gt;@Time = 1, @Time = 2, ... @Time = N&amp;lt;/code&amp;gt;, and then an expression that is used to compute all subsequent values.  The expression can get the values of variables at previous time points by using the syntax:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;ident[Time - k]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the value for &amp;lt;code&amp;gt;@Time = t&amp;lt;/code&amp;gt; is being computed, &amp;lt;code&amp;gt;X[Time - 1]&amp;lt;/code&amp;gt; refers to the value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; at the previous time period, i.e., at &amp;lt;code&amp;gt;@Time = t - 1&amp;lt;/code&amp;gt;.  What is especially useful is that the value of &amp;lt;code&amp;gt;X[Time - 1]&amp;lt;/code&amp;gt; is allowed to depend (directly or indirectly) on the variable that is defined by the [[Dynamic]] function.  This makes it possible to have cyclic loops within your model, where a variable depends on itself, as long as there is an offset to a previous time point somewhere within the dynamic loop.&lt;br /&gt;
&lt;br /&gt;
The syntax &amp;lt;code&amp;gt;X[Time - k]&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;X[@Time = @Time - k]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Slice(X, Time, @Time - k)&amp;lt;/code&amp;gt;.  The offset «k» can be a constant, or it can be computed; however, it is not allowed to refer to a position before the beginning of &amp;lt;code&amp;gt;Time&amp;lt;/code&amp;gt; -- e.g., in which &amp;lt;code&amp;gt;@Time-k &amp;lt; 1&amp;lt;/code&amp;gt;.  There must be at least one non-zero offset before the loop returns to the original [[Dynamic]] variable, so that no cycle occurs. &lt;br /&gt;
&lt;br /&gt;
You can also make use of [[Subscript]] operations to earlier time points with [[Dynamic]], such as in &lt;br /&gt;
:&amp;lt;code&amp;gt; X[Time = Ceil(Time/2)]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or equivalently, &amp;lt;code&amp;gt;Subscript(X, Time, Time/2)&amp;lt;/code&amp;gt;.  You should beware of the difference between identifying a time point by position and identifying a time point by label (associationally).  If the elements of your [[Time]] index are in increments other than ''1'', then &amp;lt;code&amp;gt;X[Time - 1]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;X[@Time = @Time - 1]&amp;lt;/code&amp;gt; refer to the previous time point, while &amp;lt;code&amp;gt;X[Time = Time - 1]&amp;lt;/code&amp;gt; may refer to a time point that doesn't even exist, or to a point other than the immediately previous time point.&lt;br /&gt;
&lt;br /&gt;
When the identifier of a variable &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is used in the definition for &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;, and both &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; belong to the same dynamic loop, then the identifier &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;'s definition implicitly refers to the value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; at the current time period.  Although the final value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; may be indexed by time, the value as seen during the evaluation of &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; does not have that dimension.  Because of this, you can can refer to the current time point being evaluated by simply using the identifier [[Time]], and you can refer to the position along the [[Time]] index as &amp;lt;code&amp;gt;@Time&amp;lt;/code&amp;gt;.  Any identifier (except those appearing in a slice or subscript operation) used in an expression is equivalent to &amp;lt;code&amp;gt;X[Time - 0]&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;Slice(X, Time, @Time)&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; belong to the same dynamic loop, then the definition of &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; should never perform an operation over the [[Time]] index on the value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;.  When you write such an expression, you presumably intend to operate over the entire [[Time]]-indexed array for &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;, which would thus implicitly refer to future points in time that have not yet been computed, and would therefore be disallowed.  However, in reality, the use of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;'s definition refers to the value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; at the current time point, so that an expression such as &amp;lt;code&amp;gt;Cumulate(X, Time)&amp;lt;/code&amp;gt; would actually be [[Cumulate|cumulating]] a constant value over time.  While that is not disallowed, it is probably not what is intended, and Analytica will issue a warning in this case.  You can usually expression operations over [[Time]] directly using [[Dynamic]], for example, instead of &amp;lt;code&amp;gt;Cumulate(X, Time)&amp;lt;/code&amp;gt; you would define &amp;lt;code&amp;gt;CumX&amp;lt;/code&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Dynamic(X, Self[Time - 1] + X)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this example shows, the keyword [[Self]] can be used to refer to the current variable that is defined by [[Dynamic]].&lt;br /&gt;
&lt;br /&gt;
== The Big Dynamic Gotcha ==&lt;br /&gt;
&lt;br /&gt;
When you refer to an identifier &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; from within a dynamic loop -- and in fact, from any variable in a dynamic loop, even if the variable is not defined as [[Dynamic]](...) -- you are implicitly referring to &amp;lt;code&amp;gt;X[Time = Time]&amp;lt;/code&amp;gt;.  In other words, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; refers to the value of &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; ''at the current time period''.  The one exception to this is if you use &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; directly in a slice or subscript operation over the [[Time]] index, e.g., &amp;lt;code&amp;gt;X[@Time = @Time - 1]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It is easy to forget this and make stupid mistakes.  Many of these mistakes involve attempts to operate over the [[Time]] index (as mentioned previously).  Some of these can be quite innocent and hard to notice, such as an attempt to get the largest time value using &amp;lt;code&amp;gt;Max(Time)&amp;lt;/code&amp;gt;.  Because [[Time]] is only the current time point, this obtains the current time value. &lt;br /&gt;
&lt;br /&gt;
You are safe in using [[Time]] in an index context -- where an index is expected.  Thus, if you want the full [[Time]] array, use &amp;lt;code&amp;gt;IndexValue(Time)&amp;lt;/code&amp;gt;.  If you want the length of the time index, use &amp;lt;code&amp;gt;Sum(1, Time)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Another trick is to place your [[Time]]-operations in a separate variable outside the dynamic loop.  For example:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable max_time := Max(Time)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you can use max_time from within your dynamic loop expressions without worrying about this mistake.&lt;br /&gt;
&lt;br /&gt;
We also want to urge you to avoid a certain reliance on this implicit [[Time]]-slicing in certain cases, since the treatment of these cases are likely to be changed in a future Analytica release.  The proposed changes are intended to eliminate the sources for the above common mistakes.  If you can avoid these cases, then you will minimize the risk of your existing models &amp;quot;breaking&amp;quot; when these enhancements appear.&lt;br /&gt;
&lt;br /&gt;
The cases to avoid are fairly esoteric, so we hope they won't impact too many people.  However, it is good to understand where they are.  Suppose &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; is a variable inside a dynamic loop, and &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; is a variable that outside of &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;'s dynamic loop.  &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; might be outside of any dynamic loop, or it may belong to a different dynamic loop -- whatever the case, &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; is not a descendant of &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt;.  The case in question then occurs when &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; in its definition, and &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; appears inside an array parameter of a function call.  For example, [[Max]](U).  The distinguishing characteristic here is that when you look at the syntax alone, it is conceivable that the function might operate over the [[Time]] index.  So, if the function obviously operates over the [[Time]] index, as in &amp;lt;code&amp;gt;Max(U, Time)&amp;lt;/code&amp;gt;, or might operate over the [[Time]] index, as in &amp;lt;code&amp;gt;Max(U)&amp;lt;/code&amp;gt;, then you should not rely on the fact that &amp;lt;code&amp;gt;U&amp;lt;/code&amp;gt; is implicitly sliced over time.&lt;br /&gt;
&lt;br /&gt;
== User-Defined Functions inside Dynamic Loops ==&lt;br /&gt;
&lt;br /&gt;
''new to [[What's new in Analytica 4.2?|Analytica 4.2]]''&lt;br /&gt;
&lt;br /&gt;
In the rare event that a [[User-Defined Function]] is part of a dynamic loop, then how the value for variable named in the definition is obtained depends on a number of factors. These rules are designed to allow a [[UDF]] to implement array operations across the dynamic index, while co-existing within a recurrence.  The ability to embed a [[UDF]] within a dynamic loop is new to Analytica 4.2.&lt;br /&gt;
&lt;br /&gt;
When a global variable identifier is evaluated from within a [[User-Defined Functions]], the current dynamic context is dropped if the variable does not belong to the same dynamic loop as the [[UDF]].  In contrast, the dynamic context passed through to the evaluation of the variable if the variable belongs to the same dynamic loop as the [[UDF]].  The following example illustrates.&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Time = 1..10&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable V := 100*1.06^(@Time - 1)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable X := Dynamic(1, F(V))&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Y := Dynamic(0, X[Time - 1])&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Function F(z) := Sum(Z + V + Y,Time)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;code&amp;gt;V&amp;lt;/code&amp;gt; is not part of any dynamic loop, and &amp;lt;code&amp;gt;X &amp;amp;rarr; Y &amp;amp;rarr; F() &amp;amp;rarr; X&amp;lt;/code&amp;gt; forms a dynamic loop.&lt;br /&gt;
&lt;br /&gt;
Consider the evaluation of &amp;lt;code&amp;gt;V&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt;'s definition when &amp;lt;code&amp;gt;Time = 2&amp;lt;/code&amp;gt;.  Since a variable always preserved dynamic context, &amp;lt;code&amp;gt;V[Time = 2]&amp;lt;/code&amp;gt; is obtained (= 106).  So &amp;lt;code&amp;gt;F(106)&amp;lt;/code&amp;gt; is called.  Inside &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt;, when &amp;lt;code&amp;gt;Z + V + Y&amp;lt;/code&amp;gt; is evaluated, these are obtained as &amp;lt;code&amp;gt;Z = 106&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;V&amp;lt;/code&amp;gt; (indexed by [[Time]]) and &amp;lt;code&amp;gt;Y[Time = 2] = 1&amp;lt;/code&amp;gt;.  The full time-indexed value for &amp;lt;code&amp;gt;V&amp;lt;/code&amp;gt; is used since it does not belong to the dynamic loop.  So at &amp;lt;code&amp;gt;Time = 2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; computes &amp;lt;code&amp;gt;(106 + V, Time)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Reverse Dynamic ==&lt;br /&gt;
&lt;br /&gt;
''new to [[What's new in Analytica 4.2?|Analytica 4.2]]''&lt;br /&gt;
&lt;br /&gt;
In many dynamic programming applications, one starts with a known ''final value'', then computes the value at each time point as a function of future values.  This ''dynamic-in-reverse'' can be accomplished using [[Dynamic]] by specifying the recurrence as the first parameter to dynamic, followed by the final value(s), and then specifying &amp;lt;code&amp;gt;reverse: true&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The example model &amp;lt;code&amp;gt;[[media:Optimal Path Dynamic Programming.ana|Optimal Path Dynamic Programming.ana]]&amp;lt;/code&amp;gt; computes the optimal path over a finite horizon.  There is a final payout in the last time period, as a function of your final state, and an action cost (a function of action and state) at each intermediate step.  Dynamic programming is used to find the optimal policy and the utility at each &amp;lt;code&amp;gt;State&amp;lt;/code&amp;gt; x &amp;lt;code&amp;gt;Action&amp;lt;/code&amp;gt; x &amp;lt;code&amp;gt;Time&amp;lt;/code&amp;gt; point:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Decision Best_Action := ArgMax(Sxa_utility, Action)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Objective Sxa_utility :=&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;Dynamic(Sxa_utility[Time + 1][Action = Best_action[Time + 1]][State = Transition] - Action_cost,&amp;lt;/code&amp;gt;&lt;br /&gt;
:::&amp;lt;code&amp;gt;Final_payout,&amp;lt;/code&amp;gt;&lt;br /&gt;
:::&amp;lt;code&amp;gt;reverse: true)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice the use of &amp;lt;code&amp;gt;[Time + 1]&amp;lt;/code&amp;gt; rather than the &amp;lt;code&amp;gt;[Time - 1]&amp;lt;/code&amp;gt; that is commonly used in forward [[Dynamic]] usages.&lt;br /&gt;
&lt;br /&gt;
== Recurrences over non-Time indexes ==&lt;br /&gt;
&lt;br /&gt;
By default, [[Dynamic]] works over the built-in Index, [[Time]]. You can use another index by giving its name in square brackets after [[Dynamic]], e.g.:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Remaining_Budget  := Dynamic[Project](Budget, Budget[Project - 1] - Project_allocation[Project - 1])&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Variable Project_Allocation := (Project_Cost &amp;lt;= Budget)*Project_Cost&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Dynamic]] is optimized for the [[Time]] index, and may run substantially slower over other Indexes.  Therefore, it is advisable to use it for indexes (other than time) with to short dimensions, and to use [[Time]] for your primary index for [[Dynamic]].&lt;br /&gt;
&lt;br /&gt;
You can have two (or more) dynamic loops using different indexes that intersect -- i.e. one or more variables is in both loops.  The example model [[media:Dynamic on multiple indexes.ana|Dynamic on multiple indexes.ana]] demonstrates using an example in which [[Dynamic]][Item] is used to allocate functions among items, then [[Dynamic]][Time] is used to carry-over unspent funds to the next time period where the allocation re-occurs.&lt;br /&gt;
&lt;br /&gt;
With intersecting dynamic loops, the result for any variable in either loop usually contains both dynamic indexes, even for variables that do not vary over one of the indexes.   For a given variable, the indexes on which there is no variation may appear in some case and not in others, depending on what order variables are evaluated.  The principle of array abstraction generally treats two arrays with differing dimensionality as equivalent if each array is constant on the dimensions that don't appear in the other. Thus, this variation in displayed functionality does not alter the actual value as far as array abstraction is concerned.  However, if you are using intersecting dynamic loops on different dynamic indexes, you should be prepared for this seemingly unusual phenomena.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Tutorial: Dynamic system model]]&lt;br /&gt;
* [[Dynamic function]]&lt;br /&gt;
* [[Dynamic Simulation]]&lt;br /&gt;
* [[Dynamic dependencies]]&lt;br /&gt;
* [[Iterate]]&lt;br /&gt;
* [[WhatIf]]&lt;br /&gt;
* [[While]]&lt;br /&gt;
* [[Slice Assignment]]&lt;br /&gt;
* [[IdentPred]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=User_defined_functions&amp;diff=48513</id>
		<title>User defined functions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=User_defined_functions&amp;diff=48513"/>
		<updated>2016-08-22T23:18:30Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to User-Defined Functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[User-Defined Functions]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Standard_deviation&amp;diff=48512</id>
		<title>Standard deviation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Standard_deviation&amp;diff=48512"/>
		<updated>2016-08-22T23:11:20Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to SDeviation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[SDeviation]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=SDeviation&amp;diff=48511</id>
		<title>SDeviation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=SDeviation&amp;diff=48511"/>
		<updated>2016-08-22T23:10:54Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Statistical Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
== SDeviation(X, ''I, w'') ==&lt;br /&gt;
Computes the weighted sample standard deviation -- the square root of the [[Variance|variance]].&lt;br /&gt;
&lt;br /&gt;
If ''X'' is an uncertain quantity, dependent on Analytica distribution functions, the variance is obtained using  [[SDeviation]](X).&lt;br /&gt;
&lt;br /&gt;
«X» is evaluated in [[Sample]] mode, and the variance along the [[Run]] index computed.&lt;br /&gt;
&lt;br /&gt;
Regardless of the variation used, the standard deviation, or weighted standard deviation, is defined as&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\sqrt(Variance(X,I,w))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Variance]] for additional technical details.&lt;br /&gt;
&lt;br /&gt;
==Optional parameters==&lt;br /&gt;
===I===&lt;br /&gt;
The optional «I» parameter can be used to calculate standard deviation along Index «I».&lt;br /&gt;
&lt;br /&gt;
Given a data set indexed by «I», the sample variance along «I» is computed using:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SDeviation(X, I)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the running index, «I», is the system index [[Run]] (or not specified), the value of «X» is evaluated in [[Sample]] mode and the average value among numeric values computed. If the running index is anything other than [[Run]], then «X» is evaluated in context. &lt;br /&gt;
&lt;br /&gt;
=== W ===&lt;br /&gt;
&lt;br /&gt;
The weighted standard deviation computing by assigning a different &amp;quot;weight&amp;quot; to each point.  The weight vector, &amp;lt;code&amp;gt;wt&amp;lt;/code&amp;gt;, should be indexed by «I» (or by [[Run]] if «I» is not specified), and the weighted variance is computed using one of these forms&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SDeviation(X, w: wt)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;SDeviation(X, I, w: wt)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the «w» parameter is not specified, and the running index «I» is either the [[Run]] index or is not specified, then the weighting defaults to the value in the system variable [[SampleWeighting]].&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Statistical_functions#Sdeviation.28x.29|Statistical functions: SDeviation]]&lt;br /&gt;
* [[Statistical Functions and Importance Weighting]]&lt;br /&gt;
* [[Variance]]&lt;br /&gt;
* [[Mean]]&lt;br /&gt;
* [[Skewness]]&lt;br /&gt;
* [[Kurtosis]]&lt;br /&gt;
* [[Statistics]]&lt;br /&gt;
* [[media:Data Statistics Library.ana|Data Statistics Library.ana]]&lt;br /&gt;
* [[Analytica_Libraries_and_Templates#Data_Statistics|Data Statistics library]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=SDeviation&amp;diff=48510</id>
		<title>SDeviation</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=SDeviation&amp;diff=48510"/>
		<updated>2016-08-22T23:10:30Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[category:Statistical Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
== SDeviation(X, ''I, w'') ==&lt;br /&gt;
Computes the weighted sample standard deviation -- the square root of the [[Variance|variance]].&lt;br /&gt;
&lt;br /&gt;
If ''X'' is an uncertain quantity, dependent on Analytica distribution functions, the variance is obtained using  [[SDeviation]](X).&lt;br /&gt;
&lt;br /&gt;
«X» is evaluated in [[Sample]] mode, and the variance along the [[Run]] index computed.&lt;br /&gt;
&lt;br /&gt;
Regardless of the variation used, the standard deviation, or weighted standard deviation, is defined as&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\sqrt(Variance(X,I,w))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Variance]] for additional technical details.&lt;br /&gt;
&lt;br /&gt;
==Optional parameters==&lt;br /&gt;
===I===&lt;br /&gt;
The optional «I» parameter can be used to calculate standard deviation along Index «I».&lt;br /&gt;
&lt;br /&gt;
Given a data set indexed by «I», the sample variance along «I» is computed using:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SDeviation(X, I)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the running index, «I», is the system index [[Run]] (or not specified), the value of «X» is evaluated in [[Sample]] mode and the average value among numeric values computed. If the running index is anything other than [[Run]], then «X» is evaluated in context. &lt;br /&gt;
&lt;br /&gt;
=== W ===&lt;br /&gt;
&lt;br /&gt;
The weighted standard deviation computing by assigning a different &amp;quot;weight&amp;quot; to each point.  The weight vector, &amp;lt;code&amp;gt;wt&amp;lt;/code&amp;gt;, should be indexed by «I» (or by [[Run]] if «I» is not specified), and the weighted variance is computed using one of these forms&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;SDeviation(X, w: wt)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;SDeviation(X, I, w: wt)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the «w» parameter is not specified, and the running index «I» is either the [[Run]] index or is not specified, then the weighting defaults to the value in the system variable [[SampleWeighting]].&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Variance]]&lt;br /&gt;
* [[Statistical_functions#Sdeviation.28x.29|Statistical functions: SDeviation]]&lt;br /&gt;
* [[Statistical Functions and Importance Weighting]]&lt;br /&gt;
* [[Mean]]&lt;br /&gt;
* [[Skewness]]&lt;br /&gt;
* [[Kurtosis]]&lt;br /&gt;
* [[Statistics]]&lt;br /&gt;
* [[media:Data Statistics Library.ana|Data Statistics Library.ana]]&lt;br /&gt;
* [[Analytica_Libraries_and_Templates#Data_Statistics|Data Statistics library]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Data_Type_Functions&amp;diff=48509</id>
		<title>Data Type Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Data_Type_Functions&amp;diff=48509"/>
		<updated>2016-08-22T23:05:59Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Data Type Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Analytica provides several functions for checking the data type of atoms (i.e., the items in an array).  These are found in the [[Special_Functions_library|Special library]].&lt;br /&gt;
&lt;br /&gt;
== Function IsHandle ==&lt;br /&gt;
&lt;br /&gt;
:'''IsHandle'''(X : Atom)&lt;br /&gt;
:'''IsHandle'''(X'', local: true'')&lt;br /&gt;
&lt;br /&gt;
Tests whether the value in «X» is a [[handle]].  When «X» is array-valued, it tests whether each cell of the array contains a handle.  The second form with &amp;lt;code&amp;gt;local: true&amp;lt;/code&amp;gt; tests whether a local variable «X» contains a [[handle]].  For details, see [[IsHandle]].&lt;br /&gt;
&lt;br /&gt;
== Function IsNaN ==&lt;br /&gt;
&lt;br /&gt;
:'''IsNaN'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
[[NaN]] is a special value arising from indeterminate arithmetic operations indicating &amp;quot;Not A Number&amp;quot;.  [[NaN]] can arise from operations such as:&lt;br /&gt;
:&amp;lt;code&amp;gt;0/0&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;0*INF&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;INF - INF&amp;lt;/code&amp;gt; &lt;br /&gt;
:&amp;lt;code&amp;gt;IgnoreWarnings(Ln(-1))&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IgnoreWarnings(Sqrt(-1))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two cases result in [[NaN]] since Analytica does not have internal support for [[Complex Numbers|complex numbers]] (see [[Ln]], [[Sqrt]] and [[IgnoreWarnings]]).  The other cases result because the result is indeterminate.  &lt;br /&gt;
&lt;br /&gt;
'''IsNaN'''(X) returns 1 (i.e., True) when «X» is the special value [[NaN]], 0 (false) otherwise.&lt;br /&gt;
&lt;br /&gt;
== Function IsNumber ==&lt;br /&gt;
&lt;br /&gt;
:'''IsNumber'''(X: Atom) &lt;br /&gt;
&lt;br /&gt;
Returns True when «X» is a number, or any of the special values [[INF]], -[[INF]], or [[NaN]]. It is also true when «X» is a complex number or a date-time number, since a date-time number is encoded as the number of days elapsed since the time origin. It returns false (zero) for text, even if the characters in the text could be parsed as a number.&lt;br /&gt;
&lt;br /&gt;
== Function IsRealNumber ==&lt;br /&gt;
&lt;br /&gt;
:'''IsRealNumber'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Returns True when «X» is a real number or the special values [[INF]] or -[[INF]]. It also returns true when «X» is a date-time number, since a date-time number is considered to be a numeric value -- the number of days elapsed since the date origin. It differs from [[IsNumber]] in that it returns false (zero) for a complex or imaginary number or for the special value [[NaN]].&lt;br /&gt;
&lt;br /&gt;
== Function IsDateTime ==&lt;br /&gt;
&lt;br /&gt;
:'''IsDateTime'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Returns True when «X» is a date-time. A date-time is a special time of number in Analytica that encodes the number of days elapsed since the date origin, which is normally ''1-Jan-1904'', or ''30-Dec-1899'' if the &amp;quot;Use Excel Date Origin&amp;quot; preference is set. The fractional part of a date-time number represents a time. When printed, date-time numbers use the Date number format.&lt;br /&gt;
&lt;br /&gt;
'''IsDateTime'''(X) is false for numbers other than those recognized as date-time numbers. It is also false for text values, even if the text itself appears to be a date or time.&lt;br /&gt;
&lt;br /&gt;
== Function IsReference ==&lt;br /&gt;
&lt;br /&gt;
:'''IsReference'''(X)&lt;br /&gt;
&lt;br /&gt;
Returns 1 (True) when «X» is a reference, 0 otherwise.  When «X» is a reference, you can use the [[#X operator]].&lt;br /&gt;
&lt;br /&gt;
== Function IsText ==&lt;br /&gt;
&lt;br /&gt;
:'''IsText'''(X: Atom) &lt;br /&gt;
&lt;br /&gt;
Returns 1 (True) when «X» is a textual string, 0 otherwise.&lt;br /&gt;
&lt;br /&gt;
== Comparison to Null ==&lt;br /&gt;
&lt;br /&gt;
The expressions &amp;lt;code&amp;gt;X = Null&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;X &amp;lt;&amp;gt; Null&amp;lt;/code&amp;gt; can be used to test whether «X» is the special system constant [[Null]].  [[Null]] results from certain operations where the value is not found, such as &amp;lt;code&amp;gt;A[I = X]&amp;lt;/code&amp;gt; when &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is not an element of &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; (and warnings are ignored).&lt;br /&gt;
&lt;br /&gt;
[[Null]] can also be detected using '''IsUndef'''(X).&lt;br /&gt;
&lt;br /&gt;
== Function IsUndef ==&lt;br /&gt;
&lt;br /&gt;
:'''IsUndef'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Returns True if «X» is either of the two special system constants [[Undefined]] or [[Null]].  [[Undefined]] is a special system constant indicating that an attribute does not yet have a value, and also used to indicate that a value is not yet computed (e.g., that the ([[Mid]]) value or [[probValue]] attribute do not yet have a value), or that an optional parameter to a function was not specified.  [[Null]] is a value returned by function evaluations indicating that a requested value is out-of-range or does not exist.  &lt;br /&gt;
&lt;br /&gt;
The special value [[Null]] was introduced into Analytica 3.0.  Prior to that, many functions returned [[Undefined]] when values did not exist, but were changed to return [[Null]].  To handle backward compatibility where the '''IsUndef''' function was being used to test for these values, '''IsUndef''' returns True in both cases.&lt;br /&gt;
&lt;br /&gt;
== Function IsNull ==&lt;br /&gt;
&lt;br /&gt;
:'''IsNull'''(X)&lt;br /&gt;
&lt;br /&gt;
Returns True if «X» is exactly [[Null]].  Returns False when «X» is another than [[Null]].  Does not [[Array Abstraction|array abstract]], so if «X» is an array, even an array containing [[Null]] cells, it still returns atomic False.  If you want to compare the cells of an array individually to [[Null]], use &amp;lt;code&amp;gt;x = Null&amp;lt;/code&amp;gt;.  If you want to test whether an attribute is set, use&lt;br /&gt;
:'''IsNull'''(attrib Of obj)&lt;br /&gt;
&lt;br /&gt;
which will return False (0) if the attribute happens to contain an array with [[Null]].&lt;br /&gt;
&lt;br /&gt;
Note that '''IsNull''' is different from the other '''''IsXXXX''''' functions in that it does not [[Array Abstraction|array abstract]].&lt;br /&gt;
&lt;br /&gt;
== Function IsNotSpecified ==&lt;br /&gt;
:'''IsNotSpecified'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Used within a user-defined function to determine whether an optional parameter has a value.  If the optional parameter is not specified in the function call, and if the parameter has no default value, then '''IsNotSpecified''' returns true.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
:&amp;lt;code&amp;gt;Function Fu1(A: Numeric; B: optional numeric)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Definition:&amp;lt;/code&amp;gt; &lt;br /&gt;
::&amp;lt;code&amp;gt;if IsNotSpecified(B) Then B := sqrt(A);&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;Normal(A*Time, B*sqrt(T))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Function TypeOf ==&lt;br /&gt;
&lt;br /&gt;
:'''TypeOf'''(X: Atom; Shallow: optional boolean)&lt;br /&gt;
&lt;br /&gt;
Returns the name of the atomic data type of «X» as a textual string.  When '''TypeOf''' is applied to an array, the result is an array, where each cell contains the data type of the corresponding item in the original array.  When «shallow» is true, a less detailed type description is given.  In many cases, '''TypeOf''' exposes details of the internal representation being used; hence, it is preferable to make use of the '''''IsXXX'''''() functions when possible.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! When &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is: &lt;br /&gt;
! &amp;lt;code&amp;gt;TypeOf(X)&amp;lt;/code&amp;gt; returns:&lt;br /&gt;
! &amp;lt;code&amp;gt;TypeOf(X, shallow: true)&amp;lt;/code&amp;gt; returns:&lt;br /&gt;
|-&lt;br /&gt;
| A real number stored internally in IEEE 754 double binary float format || &amp;quot;Number&amp;quot; || &amp;quot;Number&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| An integer value stored internally as a 64-bit signed integer || &amp;quot;Integer&amp;quot; || &amp;quot;Number&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A real-value stored internally in a fixed-point real number format || &amp;quot;FixedPoint&amp;quot; || &amp;quot;Number&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A date/time numeric value || &amp;quot;DateTime&amp;quot; || &amp;quot;DateTime&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A complex (imaginary) number || &amp;quot;ComplexNumber&amp;quot; || &amp;quot;ComplexNumber&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A textual value || &amp;quot;Text&amp;quot; || &amp;quot;Text&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| [[Null]] || &amp;quot;Null&amp;quot; || &amp;quot;Null&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Linear optimization Program (returned by [[DefineOptimization]]) || &amp;quot;LP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Quadratic optimization Program with linear constraints (returned by [[DefineOptimization]]) || &amp;quot;QP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Quadratically Constrained optimization Program (returned by [[DefineOptimization]]) || &amp;quot;QCP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Non-Linear optimization Program (returned by [[DefineOptimization]]) || &amp;quot;NLP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| An ODBC Record Set object || &amp;quot;RecordSet&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A parsed expression where the outermost operation is an operator || &amp;quot;Expression&amp;quot; || &amp;quot;Expression&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| A parsed expression where the outermost operation is a function call || &amp;quot;FunctionCall&amp;quot; || &amp;quot;FunctionCall&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A binary blob of data, e.g., from a Pict attribute || &amp;quot;Data&amp;quot; || &amp;quot;Data&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A [[Handle]] to an object with the class «className» || &amp;quot;''«className»''&amp;quot;, one of:&lt;br /&gt;
&amp;quot;Decision&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Variable&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Chance&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Objective&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Constraint&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Constant&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Index&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Function&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Determ&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Module&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Module&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Library&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Form&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Linkmodule&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Linklibrary&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Text&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Button&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Picture&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Formnode&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Alias&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Attribute&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Command&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Graphstyletemplate&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Sysfunction&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Keyword&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;quot;Object&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A [[Reference]] || &amp;quot;Reference&amp;quot; || &amp;quot;Reference&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| The data from an input or output attribute || &amp;quot;ObjectSet&amp;quot; || &amp;quot;ObjectSet&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The parameter to '''TypeOf''' is evaluated.  So, if you apply this to a function parameter or local variable, the type of the value is returned, even if the parameter is declared as an index or variable type.  For example:&lt;br /&gt;
:&amp;lt;code&amp;gt;Function F1(A: Variable) := TypeOf(A)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you call &amp;lt;code&amp;gt;F1(Ch1)&amp;lt;/code&amp;gt;, the type of each atom in the value of &amp;lt;code&amp;gt;Ch1&amp;lt;/code&amp;gt; is returned -- not the class of &amp;lt;code&amp;gt;Ch1&amp;lt;/code&amp;gt;.  If you wanted the class of the object, it would be easiest to use:&lt;br /&gt;
:&amp;lt;code&amp;gt;Function F2(A: Variable) := class of A&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which would return &amp;quot;Chance&amp;quot; when call &amp;lt;code&amp;gt;F2(Ch1)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[IsHandle]]&lt;br /&gt;
* [[Undefined]]&lt;br /&gt;
* [[Special Functions library]]&lt;br /&gt;
* [[Datatype functions]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Data_type_qualifiers|Data types of function parameters]]&lt;br /&gt;
* [[:Category: Data Type Functions]]&lt;br /&gt;
* [[:Category:Domain Access Functions]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Data_Type_Functions&amp;diff=48508</id>
		<title>Data Type Functions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Data_Type_Functions&amp;diff=48508"/>
		<updated>2016-08-22T23:04:46Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Data Type Functions]]&lt;br /&gt;
[[Category:Doc Status C]] &amp;lt;!-- For Lumina use, do not change --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
Analytica provides several functions for checking the data type of atoms (i.e., the items in an array).  These are found in the [[Special_Functions_library|Special library]].&lt;br /&gt;
&lt;br /&gt;
== Function IsHandle ==&lt;br /&gt;
&lt;br /&gt;
:'''IsHandle'''(X : Atom)&lt;br /&gt;
:'''IsHandle'''(X'', local: true'')&lt;br /&gt;
&lt;br /&gt;
Tests whether the value in «X» is a [[handle]].  When «X» is array-valued, it tests whether each cell of the array contains a handle.  The second form with &amp;lt;code&amp;gt;local: true&amp;lt;/code&amp;gt; tests whether a local variable «X» contains a [[handle]].  For details, see [[IsHandle]].&lt;br /&gt;
&lt;br /&gt;
== Function IsNaN ==&lt;br /&gt;
&lt;br /&gt;
:'''IsNaN'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
[[NaN]] is a special value arising from indeterminate arithmetic operations indicating &amp;quot;Not A Number&amp;quot;.  [[NaN]] can arise from operations such as:&lt;br /&gt;
:&amp;lt;code&amp;gt;0/0&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;0*INF&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;INF - INF&amp;lt;/code&amp;gt; &lt;br /&gt;
:&amp;lt;code&amp;gt;IgnoreWarnings(Ln(-1))&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IgnoreWarnings(Sqrt(-1))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The last two cases result in [[NaN]] since Analytica does not have internal support for [[Complex Numbers|complex numbers]] (see [[Ln]], [[Sqrt]] and [[IgnoreWarnings]]).  The other cases result because the result is indeterminate.  &lt;br /&gt;
&lt;br /&gt;
'''IsNaN'''(X) returns 1 (i.e., True) when «X» is the special value [[NaN]], 0 (false) otherwise.&lt;br /&gt;
&lt;br /&gt;
== Function IsNumber ==&lt;br /&gt;
&lt;br /&gt;
:'''IsNumber'''(X: Atom) &lt;br /&gt;
&lt;br /&gt;
Returns True when «X» is a number, or any of the special values [[INF]], -[[INF]], or [[NaN]]. It is also true when «X» is a complex number or a date-time number, since a date-time number is encoded as the number of days elapsed since the time origin. It returns false (zero) for text, even if the characters in the text could be parsed as a number.&lt;br /&gt;
&lt;br /&gt;
== Function IsRealNumber ==&lt;br /&gt;
&lt;br /&gt;
:'''IsRealNumber'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Returns True when «X» is a real number or the special values [[INF]] or -[[INF]]. It also returns true when «X» is a date-time number, since a date-time number is considered to be a numeric value -- the number of days elapsed since the date origin. It differs from [[IsNumber]] in that it returns false (zero) for a complex or imaginary number or for the special value [[NaN]].&lt;br /&gt;
&lt;br /&gt;
== Function IsDateTime ==&lt;br /&gt;
&lt;br /&gt;
:'''IsDateTime'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Returns True when «X» is a date-time. A date-time is a special time of number in Analytica that encodes the number of days elapsed since the date origin, which is normally ''1-Jan-1904'', or ''30-Dec-1899'' if the &amp;quot;Use Excel Date Origin&amp;quot; preference is set. The fractional part of a date-time number represents a time. When printed, date-time numbers use the Date number format.&lt;br /&gt;
&lt;br /&gt;
'''IsDateTime'''(X) is false for numbers other than those recognized as date-time numbers. It is also false for text values, even if the text itself appears to be a date or time.&lt;br /&gt;
&lt;br /&gt;
== Function IsReference ==&lt;br /&gt;
&lt;br /&gt;
:'''IsReference'''(X)&lt;br /&gt;
&lt;br /&gt;
Returns 1 (True) when «X» is a reference, 0 otherwise.  When «X» is a reference, you can use the [[#X operator]].&lt;br /&gt;
&lt;br /&gt;
== Function IsText ==&lt;br /&gt;
&lt;br /&gt;
:'''IsText'''(X: Atom) &lt;br /&gt;
&lt;br /&gt;
Returns 1 (True) when «X» is a textual string, 0 otherwise.&lt;br /&gt;
&lt;br /&gt;
== Comparison to Null ==&lt;br /&gt;
&lt;br /&gt;
The expressions &amp;lt;code&amp;gt;X = Null&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;X &amp;lt;&amp;gt; Null&amp;lt;/code&amp;gt; can be used to test whether «X» is the special system constant [[Null]].  [[Null]] results from certain operations where the value is not found, such as &amp;lt;code&amp;gt;A[I = X]&amp;lt;/code&amp;gt; when &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is not an element of &amp;lt;code&amp;gt;I&amp;lt;/code&amp;gt; (and warnings are ignored).&lt;br /&gt;
&lt;br /&gt;
[[Null]] can also be detected using '''IsUndef'''(X).&lt;br /&gt;
&lt;br /&gt;
== Function IsUndef ==&lt;br /&gt;
&lt;br /&gt;
:'''IsUndef'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Returns True if «X» is either of the two special system constants [[Undefined]] or [[Null]].  [[Undefined]] is a special system constant indicating that an attribute does not yet have a value, and also used to indicate that a value is not yet computed (e.g., that the ([[Mid]]) value or [[probValue]] attribute do not yet have a value), or that an optional parameter to a function was not specified.  [[Null]] is a value returned by function evaluations indicating that a requested value is out-of-range or does not exist.  &lt;br /&gt;
&lt;br /&gt;
The special value [[Null]] was introduced into Analytica 3.0.  Prior to that, many functions returned [[Undefined]] when values did not exist, but were changed to return [[Null]].  To handle backward compatibility where the '''IsUndef''' function was being used to test for these values, '''IsUndef''' returns True in both cases.&lt;br /&gt;
&lt;br /&gt;
== Function IsNull ==&lt;br /&gt;
&lt;br /&gt;
:'''IsNull'''(X)&lt;br /&gt;
&lt;br /&gt;
Returns True if «X» is exactly [[Null]].  Returns False when «X» is another than [[Null]].  Does not [[Array Abstraction|array abstract]], so if «X» is an array, even an array containing [[Null]] cells, it still returns atomic False.  If you want to compare the cells of an array individually to [[Null]], use &amp;lt;code&amp;gt;x = Null&amp;lt;/code&amp;gt;.  If you want to test whether an attribute is set, use&lt;br /&gt;
:'''IsNull'''(attrib Of obj)&lt;br /&gt;
&lt;br /&gt;
which will return False (0) if the attribute happens to contain an array with [[Null]].&lt;br /&gt;
&lt;br /&gt;
Note that '''IsNull''' is different from the other '''''IsXXXX''''' functions in that it does not [[Array Abstraction|array abstract]].&lt;br /&gt;
&lt;br /&gt;
== Function IsNotSpecified ==&lt;br /&gt;
:'''IsNotSpecified'''(X: Atom)&lt;br /&gt;
&lt;br /&gt;
Used within a user-defined function to determine whether an optional parameter has a value.  If the optional parameter is not specified in the function call, and if the parameter has no default value, then '''IsNotSpecified''' returns true.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
:&amp;lt;code&amp;gt;Function Fu1(A: Numeric; B: optional numeric)&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;Definition:&amp;lt;/code&amp;gt; &lt;br /&gt;
::&amp;lt;code&amp;gt;if IsNotSpecified(B) Then B := sqrt(A);&amp;lt;/code&amp;gt;&lt;br /&gt;
::&amp;lt;code&amp;gt;Normal(A*Time, B*sqrt(T))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Function TypeOf ==&lt;br /&gt;
&lt;br /&gt;
:'''TypeOf'''(X: Atom; Shallow: optional boolean)&lt;br /&gt;
&lt;br /&gt;
Returns the name of the atomic data type of «X» as a textual string.  When '''TypeOf''' is applied to an array, the result is an array, where each cell contains the data type of the corresponding item in the original array.  When «shallow» is true, a less detailed type description is given.  In many cases, '''TypeOf''' exposes details of the internal representation being used; hence, it is preferable to make use of the '''''IsXXX'''''() functions when possible.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! When &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is: &lt;br /&gt;
! &amp;lt;code&amp;gt;TypeOf(X)&amp;lt;/code&amp;gt; returns:&lt;br /&gt;
! &amp;lt;code&amp;gt;TypeOf(X, shallow: true)&amp;lt;/code&amp;gt; returns:&lt;br /&gt;
|-&lt;br /&gt;
| A real number stored internally in IEEE 754 double binary float format || &amp;quot;Number&amp;quot; || &amp;quot;Number&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| An integer value stored internally as a 64-bit signed integer || &amp;quot;Integer&amp;quot; || &amp;quot;Number&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A real-value stored internally in a fixed-point real number format || &amp;quot;FixedPoint&amp;quot; || &amp;quot;Number&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A date/time numeric value || &amp;quot;DateTime&amp;quot; || &amp;quot;DateTime&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A complex (imaginary) number || &amp;quot;ComplexNumber&amp;quot; || &amp;quot;ComplexNumber&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A textual value || &amp;quot;Text&amp;quot; || &amp;quot;Text&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| [[Null]] || &amp;quot;Null&amp;quot; || &amp;quot;Null&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Linear optimization Program (returned by [[DefineOptimization]]) || &amp;quot;LP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Quadratic optimization Program with linear constraints (returned by [[DefineOptimization]]) || &amp;quot;QP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Quadratically Constrained optimization Program (returned by [[DefineOptimization]]) || &amp;quot;QCP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A Non-Linear optimization Program (returned by [[DefineOptimization]]) || &amp;quot;NLP&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| An ODBC Record Set object || &amp;quot;RecordSet&amp;quot; || &amp;quot;Custom&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A parsed expression where the outermost operation is an operator || &amp;quot;Expression&amp;quot; || &amp;quot;Expression&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| A parsed expression where the outermost operation is a function call || &amp;quot;FunctionCall&amp;quot; || &amp;quot;FunctionCall&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A binary blob of data, e.g., from a Pict attribute || &amp;quot;Data&amp;quot; || &amp;quot;Data&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A [[Handle]] to an object with the class «className» || &amp;quot;''«className»''&amp;quot;, one of:&lt;br /&gt;
&amp;quot;Decision&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Variable&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Chance&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Objective&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Constraint&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Constant&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Index&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Function&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Determ&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Module&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Module&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Library&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Form&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Linkmodule&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Linklibrary&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Text&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Button&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Picture&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Formnode&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Alias&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Attribute&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Command&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Graphstyletemplate&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Sysfunction&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;Keyword&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;quot;Object&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| A [[Reference]] || &amp;quot;Reference&amp;quot; || &amp;quot;Reference&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| The data from an input or output attribute || &amp;quot;ObjectSet&amp;quot; || &amp;quot;ObjectSet&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The parameter to '''TypeOf''' is evaluated.  So, if you apply this to a function parameter or local variable, the type of the value is returned, even if the parameter is declared as an index or variable type.  For example:&lt;br /&gt;
:&amp;lt;code&amp;gt;Function F1(A: Variable) := TypeOf(A)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you call &amp;lt;code&amp;gt;F1(Ch1)&amp;lt;/code&amp;gt;, the type of each atom in the value of &amp;lt;code&amp;gt;Ch1&amp;lt;/code&amp;gt; is returned -- not the class of &amp;lt;code&amp;gt;Ch1&amp;lt;/code&amp;gt;.  If you wanted the class of the object, it would be easiest to use:&lt;br /&gt;
:&amp;lt;code&amp;gt;Function F2(A: Variable) := class of A&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which would return &amp;quot;Chance&amp;quot; when call &amp;lt;code&amp;gt;F2(Ch1)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[IsHandle]]&lt;br /&gt;
* [[Undefined]]&lt;br /&gt;
* [[Special Functions library]]&lt;br /&gt;
* [[Datatype functions]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Data_type_qualifiers|Data types of function parameters]]&lt;br /&gt;
* [[:Category:Domain Access Functions]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Error_Messages/40318&amp;diff=48507</id>
		<title>Error Messages/40318</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Error_Messages/40318&amp;diff=48507"/>
		<updated>2016-08-22T23:03:43Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Error messages]]&lt;br /&gt;
&lt;br /&gt;
== Error message examples  ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background:white; border:white; margin-left: 1em; font-style:italic&amp;quot;&amp;gt;&lt;br /&gt;
 Error encountered in the parameter declaration for Function CovertToText while checking:&lt;br /&gt;
 (X: coerce)&lt;br /&gt;
 In the declaration for parameter X, you must specify a datatype when you use COERCE.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Cause  ==&lt;br /&gt;
&lt;br /&gt;
'''Coerce''' &amp;lt;t&amp;gt; is a parameter qualifier in the Parameters attribute of a Function.&lt;br /&gt;
It specifies that the function, when called, should try to convert the actual parameter to the specified type &amp;lt;t&amp;gt;.&lt;br /&gt;
You omitted any type &amp;lt;t&amp;gt;. The type may be Text, Number, or Reference&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| '''From&amp;lt;br&amp;gt;''' &lt;br /&gt;
| '''To'''&amp;lt;br&amp;gt; &lt;br /&gt;
| '''Result'''&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Null&amp;lt;br&amp;gt; &lt;br /&gt;
| Text&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;quot;Null&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Number&amp;lt;br&amp;gt; &lt;br /&gt;
| Text&amp;lt;br&amp;gt; &lt;br /&gt;
| Number as text, using the number format of the variable or function calling the function.&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Text&amp;lt;br&amp;gt; &lt;br /&gt;
| Number or Positive&amp;lt;br&amp;gt; &lt;br /&gt;
| If possible, interprets it as a date or number, using the number format.&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Null&amp;lt;br&amp;gt; &lt;br /&gt;
| Reference&amp;lt;br&amp;gt; &lt;br /&gt;
| \Null&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Number&amp;lt;br&amp;gt; &lt;br /&gt;
| Reference&amp;lt;br&amp;gt; &lt;br /&gt;
| \X&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Text&amp;lt;br&amp;gt; &lt;br /&gt;
| Reference&amp;lt;br&amp;gt; &lt;br /&gt;
| \Text&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
See more at [[Function_Parameter_Qualifiers#Parameter_qualifiers|function parameter qualifiers.]]&lt;br /&gt;
&lt;br /&gt;
== Remedies  ==&lt;br /&gt;
&lt;br /&gt;
Add the type you want the parameter to be coerced to. &lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[User-Defined Functions]]&lt;br /&gt;
* [[Function calls and parameters]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Data_type_qualifiers|Data types of function parameters]]&lt;br /&gt;
* [[Function Parameter Qualifiers]]&lt;br /&gt;
* [[NumberToText]]&lt;br /&gt;
* [[Datatype functions]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Datatype_functions&amp;diff=48506</id>
		<title>Datatype functions</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Datatype_functions&amp;diff=48506"/>
		<updated>2016-08-22T23:01:42Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Analytica User Guide]]&lt;br /&gt;
[[Category: Data Type Functions]]&lt;br /&gt;
&amp;lt;breadcrumbs&amp;gt;Analytica User Guide &amp;gt; Expressions &amp;gt; {{PAGENAME}}&amp;lt;/breadcrumbs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A value can be a number, text, [[Null]], or a reference. Integers, reals, Boolean, and date values, are all represented as numbers. You can use these functions from the [[Special_Functions_library|Special]] library of [[Definition menu]] to determine the type.&lt;br /&gt;
&lt;br /&gt;
'''IsNumber(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a number, including a boolean, date, [[INF]], [[NaN]], or complex. See also [[IsNumber]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(0) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(False) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(INF) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber('hi') &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(5) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber('5') &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNumber(NAN) &amp;amp;rarr; True&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''IsText(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a text value. See also [[IsText]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;IsText('hello') &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsText(7) &amp;amp;rarr; False&amp;lt;/code&amp;gt; &lt;br /&gt;
:&amp;lt;code&amp;gt;IsText('7') &amp;amp;rarr; True&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''IsNaN(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is “not a number,” i.e., [[NaN]]. [[INF]] or regular numbers do not qualify, nor does a text or [[Null]]. See also [[IsNaN]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;0/0 &amp;amp;rarr; NAN&amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN(0/0) &amp;amp;rarr; True &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN(5) &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN(INF) &amp;amp;rarr; False &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;IsNaN('Hello') &amp;amp;rarr; False&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''IsNull(x)''': To test if «x» is exactly [[Null]]. Returns false if «x» is an array. See also [[IsNull]]().&lt;br /&gt;
&lt;br /&gt;
'''x &amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt; NULL''': To test if an atomic «x» is [[Null]]. When «x» is an array, returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; for each element of the array.&lt;br /&gt;
&lt;br /&gt;
'''IsUndef(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if atomic «x» is [[Null]] or the internal value [[Undefined]] (usually indicating uncomputed). When «x» is an array, returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; for each element of the array. See also [[IsUndef]]().&lt;br /&gt;
&lt;br /&gt;
'''IsRealNumber(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; when «x» is a real number, including a boolean, date or [[INF]]. Returns &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; when «x» is a complex number or [[NaN]]. See also [[IsRealNumber]]().&lt;br /&gt;
&lt;br /&gt;
'''IsReference(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a reference to a value. See also [[IsReference]]().&lt;br /&gt;
&lt;br /&gt;
'''IsHandle(x)''': Returns &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; if «x» is a handle to an Analytica object. See also [[IsHandle]](x).&lt;br /&gt;
&lt;br /&gt;
'''TypeOf(x)''': Returns the type of expression «x» as a text value, usually one of &amp;lt;code&amp;gt;Number, Text, Reference&amp;lt;/code&amp;gt;, or [[Null]]. [[INF]] and [[NaN]] are both of type &amp;lt;code&amp;gt;&amp;quot;Number&amp;quot;&amp;lt;/code&amp;gt;. See also [[TypeOf]]().&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf(2008) &amp;amp;rarr; &amp;quot;Number&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf('2008') &amp;amp;rarr; &amp;quot;Text&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf(INF) &amp;amp;rarr; &amp;quot;Number&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
:&amp;lt;code&amp;gt;TypeOf(0/0) &amp;amp;rarr; &amp;quot;Number&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Data Type Functions]]&lt;br /&gt;
* [[TypeOf]]&lt;br /&gt;
* [[IsNumber]]&lt;br /&gt;
* [[IsRealNumber]]&lt;br /&gt;
* [[IsNaN]]&lt;br /&gt;
* [[IsText]]&lt;br /&gt;
* [[IsReference]]&lt;br /&gt;
* [[IsHandle]]&lt;br /&gt;
* [[IsNull]]&lt;br /&gt;
* [[IsUndef]]&lt;br /&gt;
* [[Special Functions library]]&lt;br /&gt;
* [[Function_parameter_qualifiers#Data_type_qualifiers| Data types of function parameters]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;footer&amp;gt;Warnings / {{PAGENAME}} / Text, Date, Math, and Financial Functions&amp;lt;/footer&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Data_type&amp;diff=48505</id>
		<title>Data type</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Data_type&amp;diff=48505"/>
		<updated>2016-08-22T22:59:22Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Datatype functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Datatype functions]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
	<entry>
		<id>https://docs.analytica.com/index.php?title=Compound_expression&amp;diff=48504</id>
		<title>Compound expression</title>
		<link rel="alternate" type="text/html" href="https://docs.analytica.com/index.php?title=Compound_expression&amp;diff=48504"/>
		<updated>2016-08-22T22:54:28Z</updated>

		<summary type="html">&lt;p&gt;Bbecane: Redirected page to Begin-End for Grouping Expressions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Begin-End for Grouping Expressions]]&lt;/div&gt;</summary>
		<author><name>Bbecane</name></author>
	</entry>
</feed>