{ From user Lonnie, Model Statistical_function at Thu, May 22, 2008 11:01 AM~~
}
Softwareversion 4.1.0
{ System Variables with non-default values: }
Samplesize := 200
{!40000|Att_contlinestyle Run: 0}
Typechecking := 1
Checking := 1
Saveoptions := 2
Savevalues := 0
Allwarnings := 0
Sampleweighting := wt
Windstate Sampleweighting: 2,56,200,481,435
{!40000|Graph_hlabelrotation := 90}
{!40000|Att_contlinestyle Graph_primary_valdim: 1}
{!40000|Att_contlinestyle Graph_pdf_valdim: 6}
{!40000|Att_catlinestyle Graph_prob_valdim: 9}
Attribute Reference
Attribute Date_bough
Askattribute Recursive,Function,Yes
Askattribute Domain,Variable,Yes
Model Statistical_function
Title: Statistical Functions
Description: User Group Webinar, 22 May 2008~
~
A statistical function is a function that processes a data set contai~~
ning many sample points, computing a "statistic" that summarizes the ~~
data. Simple examples are Mean and Variance, but more complex example~~
s may return matrices or tables. In this talk, I'll review statistica~~
l functions that are built into Analytica 4.0. In Analytica 4.0, all ~~
built-in statistical functions can now be applied to historical data ~~
sets over an arbitrary index, as well as to uncertain samples (the Ru~~
n index), eliminating the need for separate function libraries. I wil~~
l demonstrate this use, as well as several new statistical functions,~~
e.g., Pdf, Cdf, Covariance. I will explain how the domain attribute ~~
should be utilized to indicate that numeric-valued data is discrete (~~
such as integer counts, for example), and how various statistical fun~~
ctions (e.g., Frequency, GetFract, Pdf, Cdf, etc) make use of this in~~
formation. In the process, I'll demonstrate numerous examples using t~~
hese functions, such things as inferring sample covariance or correla~~
tion matricies from data, quickly histogramming arbitrary data and us~~
ing the coordinate index setting to plot it, or using a weighted Freq~~
uency for rapid aggregation. ~
~
In addition, all statistical functions in Analytica 4.0 can compute w~~
eighted statistics, where each point is assigned a different weight. ~~
I'll cover the basics of sample weighting, and demonstrate some simpl~~
e examples of using this for computing a Bayesian posterior and for i~~
mportance sampling from an extreme distribution. ~
Author: Lonnie Chrisman
Date: Wed, May 21, 2008 8:42 PM
Saveauthor: Lonnie
Savedate: Thu, May 22, 2008 11:01 AM
Defaultsize: 48,24
Diagstate: 1,1,7,550,300,17
Windstate: 2,91,117,555,491
Fontstyle: Arial, 15
Fileinfo: 0,Model Statistical_function,2,2,0,0,W:\Training\User Group ~~
Webinars\Statistical Functions.ANA
Module Historical_data
Title: Statistical Functions applied to Historical Data
Author: Lonnie
Date: Thu, May 22, 2008 9:54 AM
Defaultsize: 48,24
Nodelocation: 96,56,1
Nodesize: 68,42
Diagstate: 1,1,7,649,420,17
Index Stock
Title: Stock
Definition: ['GOOG','MSFT','YHOO','ORCL','INTC','AAPL']
Nodelocation: 88,104,1
Nodesize: 48,24
{!40000|Att_previndexvalue: ['GOOG','MSFT','YHOO','ORCL','INTC','AAPL'~~
]}
Index Trading_date
Title: Trading Date
Definition: [37.623K,37.624K,37.625K,37.628K,37.629K,37.63K,37.631K,37~~
.632K,37.636K,37.637K,37.638K,37.639K,37.642K,37.643K,37.644K,37.645K~~
,37.646K,37.649K,37.65K,37.651K,37.652K,37.653K,37.656K,37.657K,37.65~~
8K,37.659K,37.66K,37.663K,37.664K,37.665K,37.666K,37.667K,37.671K,37.~~
672K,37.673K,37.674K,37.677K,37.678K,37.679K,37.68K,37.681K,37.684K,3~~
7.685K,37.686K,37.687K,37.688K,37.691K,37.692K,37.693K,37.694K,37.695~~
K,37.698K,37.699K,37.7K,37.701K,37.702K,37.705K,37.706K,37.707K,37.70~~
8K,37.709K,37.712K,37.713K,37.714K,37.715K,37.719K,37.72K,37.721K,37.~~
722K,37.723K,37.726K,37.727K,37.728K,37.729K,37.73K,37.733K,37.734K,3~~
7.735K,37.736K,37.737K,37.74K,37.741K,37.742K,37.743K,37.744K,37.747K~~
,37.748K,37.749K,37.75K,37.751K,37.754K,37.755K,37.756K,37.757K,37.75~~
8K,37.761K,37.762K,37.763K,37.764K,37.765K,37.769K,37.77K,37.771K,37.~~
772K,37.775K,37.776K,37.777K,37.778K,37.779K,37.782K,37.783K,37.784K,~~
37.785K,37.786K,37.789K,37.79K,37.791K,37.792K,37.793K,37.796K,37.797~~
K,37.798K,37.799K,37.8K,37.803K,37.804K,37.806K,37.807K,37.81K,37.811~~
K,37.812K,37.813K,37.814K,37.817K,37.818K,37.819K,37.82K,37.821K,37.8~~
24K,37.825K,37.826K,37.827K,37.828K,37.831K,37.832K,37.833K,37.834K,3~~
7.835K,37.838K,37.839K,37.84K,37.841K,37.842K,37.845K,37.846K,37.847K~~
,37.848K,37.849K,37.852K,37.853K,37.854K,37.855K,37.856K,37.859K,37.8~~
6K,37.861K,37.862K,37.863K,37.867K,37.868K,37.869K,37.87K,37.873K,37.~~
874K,37.875K,37.876K,37.877K,37.88K,37.881K,37.882K,37.883K,37.884K,3~~
7.887K,37.888K,37.889K,37.89K,37.891K,37.894K,37.895K,37.896K,37.897K~~
,37.898K,37.901K,37.902K,37.903K,37.904K,37.905K,37.908K,37.909K,37.9~~
1K,37.911K,37.912K,37.915K,37.916K,37.917K,37.918K,37.919K,37.922K,37~~
.923K,37.924K,37.925K,37.926K,37.929K,37.93K,37.931K,37.932K,37.933K,~~
37.936K,37.937K,37.938K,37.939K,37.94K,37.943K,37.944K,37.945K,37.947~~
K,37.95K,37.951K,37.952K,37.953K,37.954K,37.957K,37.958K,37.959K,37.9~~
6K,37.961K,37.964K,37.965K,37.966K,37.967K,37.968K,37.971K,37.972K,37~~
.973K,37.974K,37.975K,37.978K,37.98K,37.981K,37.982K,37.985K,37.987K,~~
37.988K,37.989K,37.992K,37.993K,37.994K,37.995K,37.996K,37.999K,38K,3~~
8.001K,38.002K,38.003K,38.007K,38.008K,38.009K,38.01K,38.013K,38.014K~~
,38.015K,38.016K,38.017K,38.02K,38.021K,38.022K,38.023K,38.024K,38.02~~
7K,38.028K,38.029K,38.03K,38.031K,38.035K,38.036K,38.037K,38.038K,38.~~
041K,38.042K,38.043K,38.044K,38.045K,38.048K,38.049K,38.05K,38.051K,3~~
8.052K,38.055K,38.056K,38.057K,38.058K,38.059K,38.062K,38.063K,38.064~~
K,38.065K,38.069K,38.07K,38.071K,38.072K,38.073K,38.076K,38.077K,38.0~~
78K,38.079K,38.08K,38.083K,38.084K,38.085K,38.086K,38.087K,38.09K,38.~~
091K,38.092K,38.093K,38.094K,38.097K,38.098K,38.099K,38.1K,38.101K,38~~
.104K,38.105K,38.106K,38.107K,38.108K,38.111K,38.112K,38.113K,38.114K~~
,38.115K,38.118K,38.119K,38.12K,38.121K,38.122K,38.125K,38.126K,38.12~~
7K]
Nodelocation: 88,48,1
Nodesize: 48,24
Valuestate: 2,564,282,416,303,0,MIDM
Numberformat: 2,DD,2,2,0,0,4,0,$,0,"ABBREV",0
{!40000|Att_previndexvalue: [37.623K,37.624K,37.625K,37.628K,37.629K,37.63K~~
,37.631K,37.632K,37.636K,37.637K,37.638K,37.639K,37.642K,37.643K,37.644K~~
,37.645K,37.646K,37.649K,37.65K,37.651K,37.652K,37.653K,37.656K,37.657K~~
,37.658K,37.659K,37.66K,37.663K,37.664K,37.665K,37.666K,37.667K,37.671K~~
,37.672K,37.673K,37.674K,37.677K,37.678K,37.679K,37.68K,37.681K,37.684K~~
,37.685K,37.686K,37.687K,37.688K,37.691K,37.692K,37.693K,37.694K,37.695K~~
,37.698K,37.699K,37.7K,37.701K,37.702K,37.705K,37.706K,37.707K,37.708K~~
,37.709K,37.712K,37.713K,37.714K,37.715K,37.719K,37.72K,37.721K,37.722K~~
,37.723K,37.726K,37.727K,37.728K,37.729K,37.73K,37.733K,37.734K,37.735K~~
,37.736K,37.737K,37.74K,37.741K,37.742K,37.743K,37.744K,37.747K,37.748K~~
,37.749K,37.75K,37.751K,37.754K,37.755K,37.756K,37.757K,37.758K,37.761K~~
,37.762K,37.763K,37.764K,37.765K,37.769K,37.77K,37.771K,37.772K,37.775K~~
,37.776K,37.777K,37.778K,37.779K,37.782K,37.783K,37.784K,37.785K,37.786K~~
,37.789K,37.79K,37.791K,37.792K,37.793K,37.796K,37.797K,37.798K,37.799K~~
,37.8K,37.803K,37.804K,37.806K,37.807K,37.81K,37.811K,37.812K,37.813K~~
,37.814K,37.817K,37.818K,37.819K,37.82K,37.821K,37.824K,37.825K,37.826K~~
,37.827K,37.828K,37.831K,37.832K,37.833K,37.834K,37.835K,37.838K,37.839K~~
,37.84K,37.841K,37.842K,37.845K,37.846K,37.847K,37.848K,37.849K,37.852K~~
,37.853K,37.854K,37.855K,37.856K,37.859K,37.86K,37.861K,37.862K,37.863K~~
,37.867K,37.868K,37.869K,37.87K,37.873K,37.874K,37.875K,37.876K,37.877K~~
,37.88K,37.881K,37.882K,37.883K,37.884K,37.887K,37.888K,37.889K,37.89K~~
,37.891K,37.894K,37.895K,37.896K,37.897K,37.898K,37.901K,37.902K,37.903K~~
,37.904K,37.905K,37.908K,37.909K,37.91K,37.911K,37.912K,37.915K,37.916K~~
,37.917K,37.918K,37.919K,37.922K,37.923K,37.924K,37.925K,37.926K,37.929K~~
,37.93K,37.931K,37.932K,37.933K,37.936K,37.937K,37.938K,37.939K,37.94K~~
,37.943K,37.944K,37.945K,37.947K,37.95K,37.951K,37.952K,37.953K,37.954K~~
,37.957K,37.958K,37.959K,37.96K,37.961K,37.964K,37.965K,37.966K,37.967K~~
,37.968K,37.971K,37.972K,37.973K,37.974K,37.975K,37.978K,37.98K,37.981K~~
,37.982K,37.985K,37.987K,37.988K,37.989K,37.992K,37.993K,37.994K,37.995K~~
,37.996K,37.999K,38K,38.001K,38.002K,38.003K,38.007K,38.008K,38.009K,~~
38.01K,38.013K,38.014K,38.015K,38.016K,38.017K,38.02K,38.021K,38.022K~~
,38.023K,38.024K,38.027K,38.028K,38.029K,38.03K,38.031K,38.035K,38.036K~~
,38.037K,38.038K,38.041K,38.042K,38.043K,38.044K,38.045K,38.048K,38.049K~~
,38.05K,38.051K,38.052K,38.055K,38.056K,38.057K,38.058K,38.059K,38.062K~~
,38.063K,38.064K,38.065K,38.069K,38.07K,38.071K,38.072K,38.073K,38.076K~~
,38.077K,38.078K,38.079K,38.08K,38.083K,38.084K,38.085K,38.086K,38.087K~~
,38.09K,38.091K,38.092K,38.093K,38.094K,38.097K,38.098K,38.099K,38.1K~~
,38.101K,38.104K,38.105K,38.106K,38.107K,38.108K,38.111K,38.112K,38.113K~~
,38.114K,38.115K,38.118K,38.119K,38.12K,38.121K,38.122K,38.125K,38.126K~~
,38.127K]}
Variable Stock_price
Title: Stock Price
Definition: Table(Stock,Trading_date)(~
467.59,483.26,487.19,483.58,485.5,489.46,499.72,505,504.28,497.28,487~~
.83,489.75,480.84,479.05,499.07,488.09,495.84,492.47,494.32,501.5,481~~
.75,481.5,467.16,471.48,470.01,471.03,461.89,458.29,459.1,465.93,461.~~
47,469.94,472.1,475.86,475.85,470.62,464.93,448.77,449.45,448.23,438.~~
68,440.95,457.55,455.64,454.72,452.96,454.75,443.03,448,446.19,440.85~~
,447.23,445.28,456.55,462.04,461.83,465,463.62,461.88,460.92,458.16,4~~
58.53,472.6,471.02,471.51,468.21,466.5,464.53,467.39,466.29,474.27,47~~
2.8,476.01,471.65,482.48,479.08,477.53,477.99,481.18,479.01,471.38,46~~
9,465.78,473.23,471.12,467.27,466.81,469.25,461.47,466.74,461.78,458,~~
472.61,470.96,470.32,470.6,475.86,473.97,474.33,483.52,487.11,498.6,4~~
97.91,500.4,507.07,518.84,518.25,515.06,515.49,511.34,504.77,505.24,5~~
02.84,505.89,515.2000000000001,514.31,509.97,514.11,524.98,527.42,530~~
.26,526.29,525.01,522.7000000000001,530.38,534.34,541.63,539.4,542.56~~
,543.34,544.47,545.33,552.16,552.99,555,549.5,548.59,520.12,512.51,51~~
4,509.76,508,511.89,516.11,510,512.9400000000001,511.01,503,510,516.0~~
2,525.78,514.73,515.75,515.5,508.6,497.55,491.52,500.04,497.92,506.61~~
,512.75,512.1900000000001,515,513.26,506.4,512.88,511.4,515.25,525.15~~
,527.8,523.52,519.35,514.48,521.33,522.65,524.78,528.75,525.3,535.27,~~
546.85,552.83,560.1,568.02,569,568.16,567.5,567.27,582.55,584.39,584.~~
02,579.03,594.05,609.62,615.18,625.39,622,637.39,620.11,616,633.48,63~~
9.62,644.71,650.75,675.77,675.8200000000001,668.51,674.6,679.23,694.7~~
7,707,703.21,711.25,725.65,741.79,732.9400000000001,693.84,663.97,632~~
.0700000000001,660.55,641.68,629.65,633.63,625.85,648.54,660.52,676.7~~
000000000001,666,673.5700000000001,692.26,697,693,681.53,684.16,698.5~~
1,715.26,714.87,718.42,699.2000000000001,699.35,694.05,689.96,669.23,~~
673.35,677.37,689.6900000000001,696.6900000000001,700.73,710.84,700.7~~
4,702.53,691.48,685.1900000000001,685.33,657,649.25,631.68,653.200000~~
0000001,646.73,638.25,653.8200000000001,637.65,615.9500000000001,600.~~
79,600.25,584.35,548.62,574.49,566.4,555.98,550.52,548.27,564.3,515.9~~
,495.43,506.8,501.71,504.95,516.6900000000001,521.16,518.09,534.62,53~~
2.25,529.64,508.95,509,502.86,507.8,486.44,464.19,472.86,475.39,471.1~~
8,457.02,444.6,447.7,432.7,433.35,413.62,439.84,440.18,443.01,437.92,~~
419.87,439.16,432,433.55,460.56,450.78,458.19,444.08,438.08,440.47,46~~
5.71,465.7,455.12,471.09,476.82,467.81,464.19,469.08,457.45,451.66,44~~
6.84,455.03,449.54,539.41,537.79,555,546.49,543.04,544.06,552.12,558.~~
47,574.29,593.08,581.29,594.9,586.36,579,583.01,573.2000000000001,584~~
.9400000000001,583,576.3,581,580.0700000000001,577.52,578.6,549.99,~
29.86,29.81,29.64,29.93,29.96,29.66,30.7,31.21,31.16,31.1,31,31.11,30~~
.72,30.74,31.09,30.45,30.6,30.53,30.48,30.86,30.56,30.19,29.61,29.51,~~
29.37,29.26,28.98,28.94,29.01,29.4,29.46,28.74,28.83,29.35,29.39,28.9~~
,29.07,27.87,28.17,28.09,27.76,27.55,27.83,27.61,27.32,27.29,27.44,26~~
.72,27.4,27.28,27.33,27.83,27.84,28.52,28.27,28.02,28.22,27.72,27.64,~~
27.75,27.87,27.74,27.87,28.5,28.55,28.57,28.4,28.11,28.54,28.61,28.73~~
,28.85,28.6,28.69,29.02,28.78,28.79,28.99,29.1,30.12,29.94,30.4,30.61~~
,30.97,30.56,30.71,30.75,30.78,30.58,30.89,30.97,30.9,31.07,30.98,30.~~
83,31.05,30.69,30.58,30.17,30.48,30.79,31.11,30.69,30.59,30.72,30.58,~~
30.29,29.62,30.05,30.02,29.85,30.39,30.52,30.49,30.51,30.46,30.01,30.~~
22,29.49,29.49,29.52,29.87,29.83,29.47,29.74,30.02,29.99,29.97,29.87,~~
29.33,29.49,30.07,29.82,30.03,30.78,30.92,31.51,31.16,31.19,30.8,30.7~~
1,29.98,29.39,29.4,28.99,29.3,29.52,28.96,29.54,29.55,30,29.3,28.71,2~~
8.63,28.27,28.1,27.81,28.25,28.26,28.07,28.22,28.3,28.81,28.49,27.93,~~
28.59,28.45,28.73,28.81,28.48,28.91,28.44,28.48,28.93,28.93,29.16,29.~~
04,28.73,28.93,28.67,28.42,28.65,29.08,29.56,29.5,29.49,29.46,29.77,2~~
9.7,29.45,29.71,29.84,29.84,30.1,30.23,29.91,30.17,30.04,30.32,31.08,~~
31.16,30.17,30.51,30.9,31.25,31.99,35.03,34.57,35.57,36.81,37.06,37.0~~
6,36.73,36.41,35.52,34.74,33.73,33.38,34.46,33.93,33.76,34.09,33.96,3~~
4.58,34.23,34.11,32.97,33.06,33.7,33.59,33.6,32.92,32.77,34.15,34.55,~~
34.53,34.76,34.1,34.47,35.22,35.31,34.39,34.74,34.79,35.52,36.06,36.5~~
8,36.61,35.97,36.12,35.6,35.22,35.37,34.38,34.61,33.45,34.44,34.33,33~~
.91,34.39,34,33.23,33.11,33.01,31.96,31.93,33.25,32.94,32.72,32.6,32.~~
2,32.6,30.45,30.19,29.07,28.52,28.12,28.56,28.21,28.34,28.96,28.5,28.~~
42,28.17,28.22,28.1,27.68,27.84,28.38,28.26,27.93,27.2,26.99,27.59,28~~
.12,27.57,27.87,28.05,29.28,28.63,28.62,27.96,28.3,29.42,28.62,29.18,~~
29.17,29.14,28.56,28.05,27.91,28.38,29.5,29.16,29,29.16,29.16,28.75,2~~
8.89,29.11,28.28,28.06,28.25,28.95,29.22,30,30.42,30.25,31.45,31.8,29~~
.83,28.99,28.64,28.52,29.4,29.24,29.08,29.7,29.21,29.27,29.39,29.99,2~~
9.78,29.93,30.45,29.99,29.46,28.76,28.25,~
25.61,26.85,27.74,27.92,27.58,28.7,29.2,29.45,29.29,29.05,28.12,27.64~~
,27.42,26.96,28.94,28.21,28.04,27.87,28.04,28.31,28.35,28.77,28.56,29~~
.35,29.89,30.08,29.74,29.17,29.56,30.66,31.25,31.91,32.01,31.65,31.6,~~
32.1,32.11,30.95,30.86,30.86,30.42,30.31,30.8,30.39,30.71,29.12,29.99~~
,29.56,29.86,30.06,29.88,30.03,30.33,31.29,31.26,31.36,31.66,31.55,31~~
.41,31.34,31.29,31.28,31.72,31.62,31.96,31.64,31.69,31.17,31.21,31.41~~
,31.61,32.09,28.31,27.51,27.46,27.88,28.02,28.06,28.49,28.34,28.04,27~~
.73,28.12,28.18,30.98,30.38,30.41,30.22,29.7,30.05,29.31,28.81,29.21,~~
28.57,29.75,29.35,28.92,28.61,28.41,28.58,28.4,28.38,28.7,28.78,28.59~~
,28.23,27.44,26.98,27.39,27.35,27.05,27.38,27.3,27.31,28.12,27.63,27.~~
66,27.67,27.38,27.64,27.71,27.58,27.25,27.13,26.86,27,26.99,27.1,27.2~~
,26.97,26.69,26.96,26.58,26.7,27.53,26.2,26.03,25.35,24.99,24.84,24.6~~
8,24.03,23.49,23.62,23.25,23.25,23.36,22.92,22.97,23.44,23.87,23.8,23~~
.94,24.57,23.72,23.32,22.76,23.54,23.34,23.04,23.23,23.13,23.59,23.03~~
,22.52,22.55,22.61,22.73,23.97,24.1,24.15,23.76,23.3,23.71,23.56,23.7~~
2,24.73,24.95,25.06,25.29,25.29,26.05,25.73,26.51,26.7,26.27,26.84,27~~
.04,26.95,27.17,27.15,27.88,28.05,28.37,28.36,27.65,28.48,27.86,26.69~~
,28.82,29.35,29.03,29.85,30.64,30.68,31.34,33.63,31.79,30.83,31.1,30.~~
22,31.11,31.36,29.93,27.63,26.7,25.79,24.78,26.1,25.07,25.42,26.82,26~~
.76,26.72,25.71,26.13,25.22,25.59,26.2,26.63,26.81,26.61,26.42,25.98,~~
25.96,25.63,25.2,24.47,24.54,24.38,24.06,23.04,23.02,23.31,23.64,24.0~~
1,24.05,23.96,23.71,23.45,23.26,23.72,23.84,23.16,23.18,22.61,22.56,2~~
4.09,23.36,23.7,22.91,21.95,21.22,20.78,19.86,20.01,21.69,21.94,20.78~~
,20.81,19.05,19.18,28.38,29.33,28.98,28.57,29.04,29.2,29.87,29.57,29.~~
88,29.98,29.66,29.01,28.83,28.42,28.42,28.13,28.22,28.37,28.15,27.78,~~
27.77,28.06,28.67,28.7,29.03,28.51,29,28.45,27.5,26.71,25.85,27.66,27~~
.07,27.66,27.52,28.73,28.49,28.09,28.99,28.93,28.5,27.82,28.13,28.36,~~
27.7,27.7,27.77,28.59,28.34,27.8,28.17,28.31,28.03,28.43,28.55,28.54,~~
28.08,27.3,26.8,26.43,27.36,27.41,26.81,28.67,24.37,25.72,25.64,26.22~~
,25.93,25.26,26.56,27.14,27.75,27.66,27.68,27.48,27.33,~
17.51,17.68,17.64,17.86,17.82,17.77,17.39,17.5,17.3,17.52,17.12,17.27~~
,17,17.12,17.14,16.98,17.15,17.27,17.16,17.16,17.05,17.42,17.16,17.02~~
,16.91,16.71,16.7,16.65,16.62,16.77,16.91,16.7,16.98,17.2,17.27,16.82~~
,16.82,16.29,16.43,16.77,16.71,16.37,16.88,16.49,16.69,16.63,17.07,16~~
.65,16.88,16.72,16.7,17.18,17.55,18.17,18.49,18.24,18.39,18.49,18.17,~~
18.16,18.13,18.14,18.36,18.56,18.67,18.57,18.85,18.59,18.7,18.63,18.9~~
,18.89,18.73,18.76,19,18.94,18.82,18.9,18.95,19.1,18.8,18.59,18.86,19~~
.02,19.03,19.05,18.95,18.83,18.49,18.98,18.94,18.84,18.99,19.05,19.25~~
,19.32,19.37,19.16,18.75,19.24,19.31,19.42,19.38,19.66,19.67,19.48,19~~
.35,18.73,19.06,19.21,18.84,19.3,19.64,19.86,19.79,19.88,19.53,19.68,~~
19.39,19.48,19.16,19.69,19.85,19.71,19.92,20.07,20.49,20.4,20.16,19.7~~
2,19.98,20.5,20.4,20.2,20.38,20.41,20.6,20.61,20.78,20.64,20.58,20.01~~
,19.62,19.58,19.12,19.79,20.09,19.66,20.08,19.68,20.2,20.09,19.99,19.~~
72,19.35,19.18,19.14,19.35,19.11,19.27,19.32,19.37,19.94,19.86,19.36,~~
20.13,20.21,20.28,20.72,20.73,20.54,20.16,20.17,20.46,20.54,20.45,20.~~
07,20.02,20.73,20.84,21.04,21.98,21.79,21.94,21.77,21.63,21.65,21.97,~~
21.85,21.57,21.76,22.18,22.51,22.59,22.92,22.46,22.44,22.07,21.75,21.~~
49,21.43,20.75,21.2,21.45,21.18,21,21.35,21.77,21.63,22.17,21.76,22.0~~
3,22.07,22.83,22.1,20.35,19.36,19.44,20.52,20.18,20.42,20.8,20.53,20.~~
69,20.21,20.31,19.7,19.89,20.51,20.48,20.18,20.24,20.03,21.22,21.42,2~~
1.14,21.64,21.07,21.37,21.61,21.2,20.94,21.25,20.76,22.1,22.71,22.76,~~
23,23.04,22.97,22.58,22.49,23.11,22.03,22.25,21.15,21.61,21.68,21.1,2~~
2.06,21.31,21.92,21.41,21.58,20.11,20.61,20.61,20.28,20.26,20.07,20.2~~
7,20.55,20.68,20.2,19.26,19.68,19.2,19.19,19.44,19.41,19.66,19.09,19.~~
09,19.02,19.43,18.89,18.9,18.97,19.21,19.19,19.41,18.8,18.95,18.44,18~~
.8,19.23,19,19.28,19.51,19.68,19.84,19.52,19.28,20.02,19.56,20.08,20.~~
77,21.08,20.94,19.43,19.37,19.56,20.41,20.49,20.68,20.35,20.23,19.92,~~
20.22,20.45,19.84,19.86,20.18,20.77,21.2,21.8,21.76,21.78,21.91,22.01~~
,21.59,21.51,21.76,20.85,21.82,21.51,21.55,21.5,20.99,21.1,21,21.51,2~~
1.67,21.78,21.87,21.68,22.43,22.16,22.01,~
20.35,21.17,21.1,21.01,21.03,21.52,21.92,22.13,22.3,21.04,20.65,20.82~~
,20.79,20.55,20.84,20.6,20.53,20.89,20.93,20.96,21.11,21.23,21.28,21.~~
31,21.51,21.36,21.03,20.8,20.87,21.14,21.31,21.23,21.18,20.88,20.97,2~~
0.76,20.85,20.03,19.86,19.59,19.22,19.11,19.4,19.12,19.23,19.1,19.48,~~
19.12,19.23,19.14,19.15,19.11,18.99,19.34,19.16,19.27,19.29,19.06,18.~~
86,19.09,19.13,19.13,19.31,19.38,19.58,20.1,20.68,20.47,20.5,20.46,20~~
.69,20.98,21.35,21.81,22.16,21.91,21.94,22.26,22.09,21.87,21.5,21.8,2~~
1.93,21.74,21.9,21.96,22.15,22.47,22.21,22.28,22.12,22.01,22.18,22.23~~
,22.7,22.63,22.99,22.67,21.97,22.16,22.3,22.08,22.18,22.36,22.16,21.9~~
6,21.49,21.31,21.83,21.93,22.2,22.67,23.23,24.24,24.17,24.1,23.94,24.~~
29,23.7,23.48,23.38,23.79,23.92,23.74,24.27,24.59,24.6,24.68,24.96,24~~
.97,24.57,26,25.97,25.95,26.33,25.06,25.26,24.55,24.72,24.53,24.5,24,~~
23.54,23.85,23.62,23.8,24.3,23.91,24.13,24.13,24.68,23.92,23.98,24.02~~
,23.8,23.22,23.1,23.7,24.11,23.89,24.15,24.23,24.79,24.45,23.96,25.09~~
,25.28,25.75,26.18,25.99,26.15,25.47,25.35,25.66,25.46,25.35,24.93,24~~
.85,25.41,25.68,25.81,25.87,25.98,25.89,25.91,25.76,25.86,26.37,26.38~~
,25.81,25.6,25.54,25.66,25.84,25.88,25.43,25.55,25.75,25.48,26.72,26.~~
97,26.3,26.64,26.8,26.01,25.89,25.94,26.26,26.27,26.9,26.5,26.8,26.84~~
,27.49,26.9,25.93,25.15,25.37,26.14,25.85,25.53,25.51,25.17,25.52,24.~~
63,25.07,24.37,25.11,26.19,26.34,26.08,26.25,26.31,27.22,27.98,27.73,~~
27.78,26.93,27.28,27.16,26.29,25.72,25.91,26.19,26.41,26.96,27.31,27.~~
45,26.83,26.76,26.66,25.35,24.67,22.67,22.88,22.26,22.75,22.54,21.99,~~
23.08,22.69,19.88,19.33,19,18.61,19.98,20.69,20,20.29,20.5,20.69,21.1~~
,21.77,21.2,20.12,19.92,20.05,20.27,20.68,20.9,21.21,20.46,20.11,20.1~~
6,20.38,20.3,19.82,19.94,20.69,20.77,20.49,19.97,20.01,20,20.2,19.87,~~
20.07,20.12,21.2,21.12,21.28,20.66,20.85,21.75,21.09,21.75,22.13,22.2~~
7,21.86,21.09,20.79,21.18,21.97,21.85,21.93,21.87,21.75,21.08,21.42,2~~
2.08,21.24,20.69,20.91,22.13,22.11,22.55,22.46,21.99,22.56,22.69,22.5~~
6,22.71,22.62,22.26,23.29,23.58,23.25,23.58,23.17,23.4,23.37,23.64,23~~
.76,23.84,24.97,25,24.88,24.09,23.66,~
83.8,85.66,85.05,85.47,92.56999999999999,97,95.8,94.62000000000001,97~~
.09999999999999,94.95,89.06999999999999,88.5,86.79000000000001,85.7,8~~
6.7,86.25,85.38,85.94,85.55,85.73,84.74,84.75,83.94,84.15000000000001~~
,86.15000000000001,86.18000000000001,83.27,84.88,84.7,85.3,85.2099999~~
9999999,84.83,85.90000000000001,89.2,89.51000000000001,89.06999999999~~
999,88.51000000000001,83.93000000000001,84.61,87.06,85.41,86.31999999~~
999999,88.19,87.72,88,87.97,89.87000000000001,88.40000000000001,90,89~~
.56999999999999,89.59,91.13,91.48,93.87000000000001,93.95999999999999~~
,93.52,95.84999999999999,95.45999999999999,93.24,93.75,92.91,93.65000~~
000000001,94.5,94.27,94.68000000000001,93.65000000000001,94.25,92.59,~~
92.19,90.24,91.43000000000001,90.34999999999999,90.40000000000001,90.~~
27,90.97,93.51000000000001,93.24,95.34999999999999,98.84,99.92,99.8,9~~
9.47,100.39,100.4,100.81,103.92,105.06,106.88,107.34,108.74,109.36,10~~
7.52,107.34,109.44,110.02,111.98,113.54,112.89,110.69,113.62,114.35,1~~
18.77,121.19,118.4,121.33,122.67,123.64,124.07,124.49,120.19,120.38,1~~
17.5,118.75,120.5,125.09,123.66,121.55,123.9,123,122.34,119.65,121.89~~
,120.56,122.04,121.26,127.17,132.75,132.3,130.33,132.35,132.39,134.07~~
,137.73,138.1,138.91,138.12,140,143.75,143.7,134.89,137.26,146,143.85~~
,141.43,131.76,135,136.49,131.85,135.25,135.03,134.01,126.39,125,127.~~
79,124.03,119.9,117.05,122.06,122.22,127.57,132.51,131.07,135.3,132.2~~
5,126.82,134.08,136.25,138.48,144.16,136.76,135.01,131.77,136.71,135.~~
49,136.85,137.2,138.81,138.41,140.92,140.77,140.31,144.15,148.28,153.~~
18,152.77,154.5,153.47,156.34,158.45,157.92,156.24,161.45,167.91,167.~~
86,166.79,162.23,167.25,166.98,169.58,172.75,173.5,170.42,174.36,186.~~
16,185.93,182.78,184.7,185.09,187,189.95,187.44,187.87,186.18,191.79,~~
186.3,175.47,165.37,153.76,169.96,166.11,164.3,166.39,163.95,168.85,1~~
68.46,171.54,172.54,174.81,180.22,184.29,182.22,178.86,179.81,185.5,1~~
89.95,194.3,194.21,188.54,190.86,191.83,190.39,184.4,182.98,183.12,18~~
7.21,193.91,198.8,198.95,198.57,199.83,198.08,194.84,194.93,180.05,17~~
7.64,171.25,179.4,178.02,172.69,178.78,169.04,159.64,160.89,161.36,15~~
5.64,139.07,135.6,130.01,130.01,131.54,132.18,135.36,133.75,131.65,12~~
9.36,122,121.24,125.48,129.45,124.86,129.4,127.46,124.63,122.18,123.8~~
2,121.54,119.46,119.74,119.15,122.96,129.91,125.02,121.73,124.62,124.~~
49,120.93,122.25,119.69,127.35,126.03,127.94,126.61,126.73,132.82,129~~
.67,133.27,139.53,140.98,145.06,140.25,143.01,143.5,149.53,147.49,151~~
.61,153.08,155.89,152.84,151.44,154.55,147.14,147.78,148.38,153.7,154~~
.49,161.04,168.16,160.2,162.89,168.94,169.73,172.24,175.05,173.95,180~~
,180.94,184.73,186.66,182.59,185.06,183.45,188.16,189.96,186.26,189.7~~
3,187.62,183.6,185.9,178.19~
)
Nodelocation: 200,48,1
Nodesize: 48,24
Defnstate: 2,70,370,416,303,0,MIDM
Valuestate: 2,470,11,554,399,1,MIDM
Graphsetup: {!40000|Att_contlinestyle Graph_primary_valdim:0}
Reformdef: [Stock,Trading_date]
Reformval: [Trading_date,Undefined]
{!40000|Att_xrole: -1}
{!40000|Att_yrole: -3}
{!40000|Att_coordinateindex: Stock}
Variable Mean_sp
Title: mean sp
Definition: mean(Stock_price, Trading_date)
Nodelocation: 200,104,1
Nodesize: 48,24
Valuestate: 2,570,31,416,303,0,MIDM
Variable Sd_sp
Title: sd sp
Definition: sdeviation(stock_price, Trading_date )
Nodelocation: 200,160,1
Nodesize: 48,24
Valuestate: 2,545,296,416,303,0,MIDM
Variable Day_wt
Title: day wt
Definition: Trading_date - min(Trading_date) + 1
Nodelocation: 328,48,1
Nodesize: 48,24
Variable Prob_bands
Title: prob bands
Definition: probBands(Stock_price,Trading_date)
Nodelocation: 328,104,1
Nodesize: 48,24
Valuestate: 2,555,44,429,392,1,MIDM
Reformval: [Sys_localindex('PROBABILITY'),Stock]
Variable Histo_sp
Title: histo sp
Definition: pdf(stock_price,Trading_date)
Nodelocation: 328,160,1
Nodesize: 48,24
Valuestate: 2,102,71,766,519,1,MIDM
Reformval: [Sys_localindex('STEP'),Undefined]
{!40000|Att_resultslicestate: [Stock,5,Sys_localindex('STEP'),1]}
{!40000|Att_xrole: -1}
{!40000|Att_yrole: -2}
{!40000|Att_coordinateindex: Densityindex}
Index Stock2
Title: Stock2
Definition: ['GOOG','MSFT','YHOO','ORCL','INTC','AAPL']
Nodelocation: 88,160,1
Nodesize: 48,24
Variable Corr_sp
Title: corr sp
Definition: Correlation( Stock_price, Stock_price[Stock=Stock2], Tradi~~
ng_date )
Nodelocation: 200,216,1
Nodesize: 48,24
Valuestate: 2,120,130,540,219,0,MIDM
Reformval: [Stock,Stock2]
Variable Cov_sp
Title: cov sp
Definition: Covariance( Stock_price, Stock_price[Stock=Stock2], Tradin~~
g_date )
Nodelocation: 328,216,1
Nodesize: 48,24
Valuestate: 2,584,52,541,248,0,MIDM
Reformval: [Stock,Stock2]
Library Multivariate_distrib
Title: Multivariate Distributions
Description: A library of multivariate distributions.~
~
In a multivariate distribution, each sample is a vector. This vector~~
is identified by an index, identified by the I parameter of the func~~
tions in this library. A Mid value from a distribution function will~~
therefore be indexed by I, whlie a Sample from a distribution functi~~
on is indexed by both I and Run. These distribution functions can al~~
so be used from within the Random function to generate a single monte~~
-carlo sample, which will be indexed by I.~
~
This library also contains functions for generating correlated distri~~
butions. Correlate_with, for example, allows you to generate a univa~~
rite distribution with an arbitrary marginal distribution that has a ~~
specified rank correlation with an arbitrary reference distribution. ~~
Several functions may be used for generating serial correlations, w~~
here each distribution along an index is correlated with the previous~~
point along that index.
Author: Lonnie Chrisman, Ph.D.~
Lumina Decision Systems~
~
With contributions by:~
John Bowers, US FDA.~
Max Henrion, Lumina Decision Systems
Date: Fri, Aug 01, 2003 7:12 PM
Saveauthor: Lonnie
Savedate: Tue, Nov 20, 2007 10:36 AM
Defaultsize: 48,24
Nodelocation: 456,56,0
Nodesize: 64,28
Nodeinfo: 1,1,1,1,1,1,0,0,0,0
Diagstate: 1,42,10,649,1009,17
Windstate: 2,401,199,483,316
Fontstyle: Arial, 15
Function Wishart( cv : Number[I,J,Run] ; n :positive ; I,J : Index ; ~
singleSampleMethod : optional hidden scalar)
Title: Wishart(cv,n,I,J)
Description: Suppose you sample N samples from a Gaussian(0,cv,I,J) di~~
stribution, X[I,R]. (R is the index that indexes each sample, R:=1..~~
N). The Wishart distribution describes the distribution of sum( X * ~~
X[I=J], R ). This matrix is dimensioned by I and J and is called the~~
scatter matrix. ~
~
A sample drawn from the Wishart is therefore a sample scatter matrix.~~
If you divide that sample by (N-1), you have a sampled covariance m~~
atrix. ~
~
If you compute a sample covariance matrix from data, and then want to~~
use this in your model, if you just use it directly, you'll be ignor~~
ing sampling error. That may be insignificant of N is large. Otherw~~
ise, you may want to use:~
Wishart( SampleCV, N, I, J) / (N-1)~
instead of just SampleCV in your model. The extended variance will ~~
account for the uncertainty from the finite sample size that was used~~
to obtain your sample CV.~
~
If you can express a prior probability on covariances in the form of ~~
an InvertedWishart distribution, then the posterior distribution, aft~~
er having computed the sample covariance matrix (assumed to be drawn,~~
by nature, from a Wishart), is also an InvertedWishart.
Definition: var T := if i0~
Each sample of a Dirichlet distribution produces a random vector whos~~
e elements sum to 1. It is commonly used to represent second order p~~
robability information.~
~
The Dirichlet distribution has a density given by ~
k * Product( X^(alpha-1), I)~
where k is a normalization factor equal to~
GammaFn( sum(alpha,I )) / Sum(GammaFn(alpha),I)~
~
The parameters, alpha, can be interpreted as observation counts. The~~
mean is given by the relative values of alpha (normalized to 1), but~~
the variance narrows as the alphas get larger, just as your confiden~~
ce in a distribution would narrow as you get more samples.~
~
The Dirichlet lends itself to easy Bayesian updating. If you have a ~~
prior of alpha0, and you observe N
Definition: var a:=Gamma(alpha,singleSampleMethod:singleSampleMethod);~~
~
a/sum(a,I)
Nodelocation: 272,120,1
Nodesize: 58,16
Windstate: 2,26,18,624,485
Paramnames: alpha,I,Over
Function Binormal(MeanVec :numeric[I,Run]; Sdeviations : positive[I,Ru~~
n]; I:IndexType; correlationCoef : numeric[Run];~
Over : ... optional atomic ;~
singleSampleMethod : optional hidden scalar)
Title: BiNormal (m, s, i, c )
Description: A 2-D Normal (or Bi-variate Gaussian) distribution with t~~
he indicated individual standard deviations (>0) and the indicated co~~
rrelation coefficient. The index, I, must have exactly 2 elements, S~~
deviations must be indexed by I.
Definition: if size(I)<>2 then ~
Error("Index to BiNormal must have 2 elements")~
else begin~
var s := product(Sdeviations,I) * correlationCoef;~
Index J:=CopyIndex(I);~
Gaussian( meanVec, If I<>J Then s else Sdeviations^2, I,J,~
singleSampleMethod: singleSampleMethod )~
end
Nodelocation: 288,72,1
Nodesize: 78,16
Windstate: 2,2,24,525,540
Paramnames: MeanVec,Sdeviations,I,correlationCoef,Over
Function Multinomial(N:Positive ; theta:NonNegative ; I : IndexType;~
Over : ... optional atomic ;~
singleSampleMethod : hidden optional scalar )
Title: Multinomial (n, theta, i )
Description: Returns the Multinomial Distribution.~
~
The multinomial distribution is a generalization of the Binomial dist~~
ribution to N possible outcomes. For example, if you were to roll a ~~
fair die N times, an outcome would be the number of times each of the~~
six numbers appears. Theta would be the probability of each outcome~~
, where sum(theta,I)=1, and index I is the list of possible outcome. ~~
If theta doesn't sum to 1, it is normalized.~
~
Each sample is a vector indexed by I indicating the number of times t~~
he corresponding outcome (die number) occurred during that sample poi~~
nt. Each sample will have the property that sum( result, I ) = N.
Definition: var z := n;~
var k := size(I);~
~
var j:=cumulate(1,I) in I do begin~
Index I2 := j..k;~
var theta2 := Slice(theta,I,I2); /* unnormalized sub-process */~
var p := theta2/sum(theta2, I2);~
p := if IsNan(p) then 0 else p;~
var xj := Binomial(z,p[I2=j],~
singleSampleMethod:singleSampleMethod);~~
~
z := z - xj;~
xj~
end~
Nodelocation: 117,120,1
Nodesize: 85,16
Windstate: 2,75,167,476,522
Paramnames: N,theta,I,Over
Function Correlate_dists(dists : Context[I,RunIndex] ; rankcorrs : num~~
eric array[I,J] ; ~
I,J : IndexType;~
RunIndex : optional Index = Run )
Title: Correlate Dists (d, rc, i, j )
Description: Reorders the samples in dists so as to match the desired~~
rank correlations between distributions as closely as possible. Ran~~
kCorrs must be positive definite, and the diagonal should contain all~~
ones.~
~
The result will be distributions having the same margins as the origi~~
nal input, but with rank correlations close to those of the rankcorrs~~
matrix.
Definition: if not IsSampleEvalMode and Handle(RunIndex)=Handle(Run) T~~
hen~
dists {Mid mode}~
Else begin~
var u := if Handle(RunIndex)=Handle(run) ~
Then Sample(Gaussian(0,rankcorrs,I,J))~
Else Random(Gaussian(0,rankcorrs,I,J),Over:RunIndex);~
var dsort := sortIndex(dists,RunIndex);~
var urank := Rank(u,RunIndex);~
dists[RunIndex=dsort[RunIndex=urank]]~
end
Nodelocation: 136,392,1
Nodesize: 100,16
Windstate: 2,301,193,494,399
Paramnames: dists,rankcorrs,I,J,RunIndex
Function Correlate_with( S, ref : Context[RunIndex] ; rc : scalar ; ~
RunIndex : optional Index = Run )
Title: Correlate With (s, ref, rc )
Description: Reorders the samples of S so that the result is correlate~~
d with the reference sample with a rank correlation close to rankcorr~~
. ~
~
Example: To generate a logNormal distribution that is highly correlat~~
ed with Ch1, use, e.g.,: Correlate_With( LogNormal(2,3), Ch1, 0.8 )~
~
Note: This achieves a given unweighted rank correlation. If you have~~
a non-default SampleWeighting of points, the weighted rank correlato~~
n may differ.
Definition: if IsSampleEvalMode or Handle(runIndex)<>Handle(Run) Then ~~
begin~
Index q := 1..2;~
var u := If Handle(RunIndex)=Handle(Run) ~
Then binormal( 0, 1, q, rc )~
Else Random(binormal(0,1,q,rc),Over:RunIndex);~
var rrank := Rank(ref,RunIndex);~
var u1sort := sortIndex(u[q=1],RunIndex);~
var u2rank := Rank(u[q=2],RunIndex);~
var ssort := sortIndex(S,RunIndex);~
S[RunIndex=ssort[RunIndex=u2rank[RunIndex=~
u1sort[Ru~~
nIndex=rrank]]]]~
end ~
else {mid mode}~
S
Nodelocation: 128,312,1
Nodesize: 96,16
Windstate: 2,205,170,545,485
Paramnames: S,ref,rc,RunIndex
Function Uniformspherical(I : IndexType ; R : optional Numeric[I,Run] ~~
;~
Over : ... optional atomic ;~
singleSampleMethod : optional hidden scalar )
Title: Uniform Spherical (i, r )
Description: Generates points uniformly on a sphere (or circle or hype~~
rsphere).~
Each sample generated is indexed by I -- so if I has 3 elements, the ~~
points will lie on a sphere.~
~
The mid value is a bit strange here since there isn't really a median~~
that lies on the sphere. Obviously the center of the sphere is the ~~
middle value, but that isn't in the allowable range. So, an arbitrar~~
y point on the sphere is used.
Definition: if IsNotSpecified(R) then R:=1;~
var u := Normal(0,1,over:I,~
singleSampleMethod:singleSampleMethod); ~
var d := sqrt( sum(u^2,I) );~
ifall d=0 and @I then R/sqrt(size(I)) else r*u/d
Nodelocation: 328,168,1
Nodesize: 86,16
Windstate: 2,151,227,476,424
Paramnames: I,R,Over
Function Multiuniform(corr : Numeric[I,J,Run] ; I,J : IndexType ; lb,u~~
b : optional Numeric[I,J,Run] ;~
Over : ... optional atomic ;~
singleSampleMethod : hidden optional scalar )
Title: MultiUniform ( c, i, j, lb, ub )
Description: The multi-variate uniform distribution.~
Generates vector samples (indexed by I) such that each component has ~~
a uniform marginal distribution, and such that each component have th~~
e pair-wise correlations given by corr. Indexes I and J must have th~~
e same number of elements, corr needs to be symmetric and must obey a~~
certain semidefinite condition (namely that the transformed matrix [~~
2*sin(30*cov) ] is positive semidefinite. In most cases, this rough~~
ly the same as corr being, or not being, positive semidefinite). Lb ~~
and ub can be used to specify upper and lower bounds, either for all ~~
components, or individually if these bounds are indexed by I. If lb ~~
& ub are omitted, each component will have marginal Uniform(0,1).~
~
The correlation specified in corr is true sample correlation - not ra~~
nk correlation. ~
~
The transformation here is based on:~
* Falk, M. (1999), "A simple approach to the generation of uniformly ~~
distributed random variables with prescribed correlations," Comm. in ~~
Stats - Simulation and Computation 28: 785-791.
Definition: if IsNotSpecified(lb) then lb:=0;~
if IsNotSpecified(ub) then ub := 1;~
var R := if I=J then 1 else 2*sin(30*corr);~
var g := Gaussian(0,R,I,J,~
singleSampleMethod:singleSampleMethod);~~
~
Cumnormal( g ) * (ub-lb) + lb
Nodelocation: 132,168,1
Nodesize: 100,16
Windstate: 2,67,106,608,611
Paramnames: corr,I,J,lb,ub,Over
Module Depricated_multi_var
Title: Depricated multi-variate stuff
Description: Functions found in this module are here for legacy reason~~
s. They existed in older versions of the Multivariate library, but h~~
ave been become obsolete for whatever reason.
Author: Lonnie
Date: Mon, Apr 30, 2007 3:49 PM
Defaultsize: 48,24
Nodelocation: 80,944,1
Nodesize: 56,32
Function Samplecovariance(X ; I : Index ; J : optional Index ; R : Ind~~
ex)
Title: Sample Covariance
Description: This function is obsolete. In Analytica 4.0, the builtin~~
function Variance can be used to compute a covariance matrix. The e~~
quivalent of this function would be: Variance( X, R, CoVarDim:I, CoV~~
arDim2:J ).~
~
Returns a covariance matrix based on the sampled data, X, indexed by ~~
I and R. (I is the dimensionality of X, R corresponds to the samples~~
). The result will be indexed by I and J -- supply J to be the same ~~
length as I.~
~
Note that the mean is simply Average(X,R), and doen't warrant a separ~~
ate function.
Definition: var I2 := if IsNotSpecified(J) ~
Then (Index K/((identifier of I)&"2") := I do VarTerm(K~~
)) ~
Else VarTerm(J);~
var Z:=X-Average(X,R);~
var Zt := Z[@I=@I2];~
Sum(Z*Zt,R)/(size(R)-1)
Nodelocation: 80,48,1
Nodesize: 48,24
Windstate: 2,222,299,476,297
Paramnames: X,I,J,R
Function Samplecorrelation(X : array[I,R] ; I,J,R : IndexType)
Title: sample correlation
Description: This function is obsolete. A covariance matrix can be co~~
mputed in Analytica 4.0+ using the built-in function Correlation. Th~~
e equivalent of this function is Correlation(X,X[@I=@J],R).~
~
Returns a correlation matrix based on data in X, where each data poin~~
t is a vector indexed by I, and the entries in the correlation matrix~~
are the pair-wise correlations of the columns of data. A second ind~~
ex, J, of size identical to I, is required in order to index the 2-di~~
mensional result.
Definition: var z:=x-average(x,R);~
var zt := slice(z,I,cumulate(1,J));~
sum(z*zt,R) / sqrt(sum(z^2,R) * sum(zt^2,R))~
Nodelocation: 208,48,1
Nodesize: 48,24
Windstate: 2,70,24,523,377
Paramnames: X,I,J,R
Close Depricated_multi_var
Text Multvar_te1
Description: Parametric Multivariate Distributions
Nodelocation: 160,40,-1
Nodesize: 136,12
Text Multvar_te2
Description: Creating an array of mutually correlated distributions:
Nodelocation: 232,368,-1
Nodesize: 200,16
Text Multvar_te3
Description: Creating a single univariate distribution correlated wit~~
h another existing dist:
Nodelocation: 296,280,-1
Nodesize: 268,12
Function Normal_correl(m, s, r, y: Numeric ;~
over : optional atomic ;~
singleSampleMethod : optional hidden scalar )
Title: Normal_correl(m, s, r, y)
Description: Generates a normal distribution with mean m, standard dev~~
iation s, and correlation r with normally distributed value y. In a ~~
deterministic context, it will return m.~
~
If y is not normally distributed, the result will also not be normal,~~
and the correlation will be approximate. It generalizes appropriatel~~
y if any of the parameters are arrays:The result array will have the ~~
union of the indexes of the parameters.
Definition: IF r<-1 OR r>1 THEN Error('Correlation parameter r in func~~
tion Normal_correl(m, s, r, y) is outside the expected range [-1, 1].~~
');~
IFOnly IsSampleEvalMode ~
THEN m + s * (Sqrt(1-r^2) ~
* Normal(Sameindexes( 0, m ), Sameindexes( 1,~~
s ),~
singleSampleMethod:singleSampl~~
eMethod ) ~
+ r * (y - Mean(y))/Sdeviation(y))~
ELSE m
Nodelocation: 352,312,1
Nodesize: 108,16
Windstate: 2,102,90,503,416
Paramnames: m,s,r,y,over
Module Multivariate_interna
Title: Multivariate Internal Functions
Author: Lonnie
Date: Tue, May 01, 2007 9:29 PM
Defaultsize: 48,24
Nodelocation: 200,944,1
Nodesize: 52,32
Function Sameindexes(x, y)
Title: SameIndexes(x,y)
Description: Returns an array with the same indexes as y, and value x ~~
in each cell.
Definition: IF y=y THEN x ELSE x
Nodelocation: 120,64,1
Nodesize: 80,20
Paramnames: x,y
Close Multivariate_interna
Function Multinormal(m, s: Numeric; cm: ArrayType[i, j,Run]; i , j: In~~
dexType ;~
Over : ... optional atomic ;~
singleSampleMethod : optional hidden scalar )
Title: Multinormal(m,s,c,i,j)
Description: A multi-variate normal (or Gaussian) distribution with me~~
an m, standard deviation s, and correlation matrix cm. m and s may ~~
be scalar or indexed by i. cm must be symmetric, positive-definite, a~~
nd indexed by i & j, which must be the same length.~
~
Multinormal uses a correlation matrix. Compare with Gaussian, which ~~
also defines a multi-variate normal but which uses a covariance matri~~
x.
Definition: Gaussian(m,cm*s*s[@i=@j],i,j,over,singleSampleMethod)
Nodelocation: 472,72,1
Nodesize: 84,16
Windstate: 2,391,248,512,343
Paramnames: m,s,cm,i,j,Over
Text Multvar_te4
Description: Reshaped distributions:
Nodelocation: 136,448,-1
Nodesize: 100,16
Function Dist_reshape(x : Numeric[R] ; newdist : all Numeric[R] ; ~
R : optional Index = Run )
Title: Dist_reshape(x, newdist)
Description: Reshapes the probability distribution of uncertain quanti~~
ty x so that it has the same marginal probability distribution (i.e, ~~
same set of sample values) as newdist, but retains the same ranks as ~~
x. Thus:~
Rank(Sample(x), Run) ~
= Rank(Sample(Reshape_dist(x, y)), Run)~
In a Mid context, it simply returns the mid value of newdist, with an~~
y indexes of x.~
~
The result retains any rank correlations that x may have with other p~~
redecessor variables. So, the rank-order correlation between a third~~
variable z and x will be the same as the rank-order correlation betw~~
een z and a reshaped version of x, i.e.~
RankCorrel(x, z) = RankCorrel(Reshape_Dist(x, y), z)~
~
The operation may optionally be applied along an index other than Run~~
.
Definition: IFOnly IsSampleEvalMode or Handle(R)<>Handle(Run) THEN BEG~~
IN~
VAR dsort := SortIndex(newdist, Run);~
VAR xranks := Rank(x, Run);~
newdist[Run = dsort[Run=xranks]]~
END~
ELSE newdist * (x=x)
Nodelocation: 152,472,1
Nodesize: 116,16
Windstate: 2,102,90,646,469
Paramnames: x,newdist,R
Text Multvar_te5
Description: Arrays with serial correlation
Nodelocation: 208,532,-1
Nodesize: 168,12
Function Normal_serial_correl(m, s, r: Numeric; i: IndexType ;~
over : ... optional atomic;~
singleSampleMethod : optional hidden scalar )
Title: Normal_serial_correl(m,s,r,i)
Description: Generates an array over index i of normal distributions w~~
ith mean m, standard deviation s, and correlation r between successiv~~
e values over index i. You can give each distribution a different m~~
ean and/or standard deviation if m and/or s are arrays indexed by i. ~~
If r is indexed by i, r[i=k] specifies the correlation between result~~
[i=k] and result[i=k-1]. (Then the first correlation, slice(r, i, 1)~~
is ignored.)
Definition: Var x := Normal(0, 1,singleSampleMethod:singleSampleMethod~~
);~
(FOR j := i DO ~
x := Normal_correl( 0, 1, r[i = j],x,~
singleSampleMethod:singleSampl~~
eMethod ) ) ~
* s + m
Nodelocation: 160,560,1
Nodesize: 120,16
Windstate: 2,353,325,540,383
Paramnames: m,s,r,i,over
Function Normal_additive_gro(x, m, s, r: Numeric; i: IndexType ;~
over : ... optional atomic ;~
singleSampleMethod : optional hidden scalar )
Title: Normal_additive_gro(x,m,s,r,i)
Description: Adds a normally distributed percent growth g with mean m ~~
and standard deviation s to x for each value of index i. The growth g~~
for each i has serial correlation r with g for i-1.
Definition: x *( 1 + Cumulate(Normal_serial_correl(m, s, r, i,~
singleSampleMethod:singleSampleMethod), i~~
))
Nodelocation: 159,600,1
Nodesize: 119,16
Windstate: 2,102,90,519,306
Paramnames: x,m,s,r,i,over
Function Normal_compound_gro(x, m, s, r: Numeric; t: IndexType ;~
over : ... optional atomic;~
singleSampleMethod : optional hidden scalar )
Title: Normal_compound_gro(x,m,s,r,t)
Description: An array of values over time index t, starting from with ~~
value x, and with compound growth applied for each time interval, wit~~
h normal uncertainty with mean m and standard deviation s The growth~~
g for each i has correlation r with g for i-1.
Definition: x * Cumproduct(IF t = Slice(t, 1) THEN 1 ELSE Normal_seria~~
l_correl(m, s, r, t, singleSampleMethod:singleSampleMethod ) + 1, t)~~
Nodelocation: 159,640,1
Nodesize: 119,16
Windstate: 2,102,90,529,366
Paramnames: x,m,s,r,t,over
Function Dist_serial_correl(x; r; i: IndexType ;~
over : ... optional atomic;~
singleSampleMethod : optional hidden scalar )
Title: Dist_serial_correl(x,r,i)
Description: Generates an array y over index i where each y[i] has a m~~
arginal distribution identical to x, and serial rank correlation of ~~
r with y[i-1]. If x is indexed by i, each y[i] has the same margin~~
al distribution as x[i], but with samples reordered to have the speci~~
fied rank correlation r between successive values. If r is indexed b~~
y i, r[i=k] specifies the rank correlation between y[i=k] and y[i=k-1~~
]. Then the first correlation, r[i=1], is ignored.~
~
In Mid context, it returns Mid(x).~
~
Note: The result retains no probabilistic dependence on x.
Definition: Dist_reshape(Normal_serial_correl( 0, 1, r, i, singleSampl~~
eMethod:singleSampleMethod ), x)
Nodelocation: 408,560,1
Nodesize: 120,16
Windstate: 2,302,78,477,447
Paramnames: x,r,i,over
Function Dist_additive_growth(x, g, r: Numeric; i: IndexType;~
over : ... optional atomic;~
singleSampleMethod : optional hidden scalar )
Title: Dist_additive_growth(x,g,r,i)
Description: Generates an array of values over index i, with the first~~
equal to x, and successive values adding an uncertain growth with pr~~
obability distribution g, and serial correlation r between growth[i =~~
k] and growth[i=k-1]. x, g, and r each may be indexed by i if you w~~
ant them to vary over i.
Definition: x + Cumulate(Dist_serial_correl( g, r, i, singleSampleMeth~~
od : singleSampleMethod), i)
Nodelocation: 407,600,1
Nodesize: 119,16
Windstate: 2,102,90,506,300
Paramnames: x,g,r,i,over
Function Dist_compound_growth(x, g, r; i: IndexType ;~
over : ... optional atomic ;~
singleSampleMethod : optional hidden scalar )
Title: Dist_compound_growth(x,g,r,i)
Description: Starts with x and applies a compound growth g for each va~~
lue of index i. The growth g for each i has correlation r with g for ~~
i-1.
Definition: x * Cumproduct(~
IF i = Slice(i, 1) THEN 1 ~
ELSE (Dist_serial_correl( g, r, i, ~
singleSampleMethod:singleSampleMe~~
thod ) + 1)~
, i)
Nodelocation: 407,640,1
Nodesize: 119,16
Windstate: 2,102,90,489,307
Paramnames: x,g,r,i,over
Text Multvar_te6
Description: Distributions on Linear Regression coefficients
Nodelocation: 296,688,-1
Nodesize: 256,12
Function Regressionnoise( Y : Numeric[I,Run] ; B : Numeric[I,K,Run] ; ~~
I,K : Index; C : optional Numeric[K,Run] )
Title: RegressionNoise(Y,B,I,K,C)
Description: When you have data, Y[I] and B[I,K], generated from an un~~
derlying model with unknown coefficients C[k] and S of the form:~
~
Y = Sum( C*B, I) + Normal(0,S)~
~
This function computes an estimate for S. ~
~
When using in conjunction with RegressionDist, it is most efficient t~~
o provide the optional parameter C to both routines, where C is the e~~
xpected value of the regression coefficients, obtained from calling R~~
egression(Y,B,I,K). Doing so avoids an unnecessary call to the built~~
in Regression function.
Definition: if IsNotSpecified(C) Then C := Regression(Y,B,I,K);~
Var resid := Y - Sum(C*B,K);~
sqrt( Sum(resid^2,I) / (size(I)-size(K)) );~
Nodelocation: 384,736,1
Nodesize: 104,20
Windstate: 2,332,211,498,542
Paramnames: Y,B,I,K,C
Function Regressionfitprob( Y : Numeric[I,Run] ; B : Numeric[I,K,Run] ~~
; I,K : Index; C : optional Numeric[K,Run] ; ~
S : optional Numeric[I,Run] )
Title: RegressionFitProb(Y,B,I,K,C)
Description: Once you've obtained regression coefficients C (indexed b~~
y K) by calling the Regression function, this function returns the pr~~
obability that a fit this poor would occur by chance, given the assum~~
ption that the data was generated by a process of the form:~
~
Y = Sum( C*B,K) + Normal(0,S)~
~
If this result is very close to zero, it probably indicates that the ~~
assumption of linearity is bad. If it is very close to one, then it ~~
validates the assumption of linearity.~
~
This is not a distribution function - it does not return a sample whe~~
n evaluated in Sample mode. However, it does complement the multivar~~
iate RegressionDist function also included in this library.~
~
To use, first call the Regression function, then you must either know~~
the measurement knows a priori, or obtain it using the RegressionNoi~~
se function.~
~
Var E_C := Regression(Y,B,I,K);~
Var S := RegressionNoise(Y,B,I,K,C);~
Var PrThisPoor := RegressionFitProb(Y,B,I,K,E_C,S)
Definition: var resid := Y - sum(C*B,K);~
var n := size(I);~
var chi2 := sum( resid^2 / Mean(S)^2, I);~
GammaI( n/2 - 1, chi2/2 )
Nodelocation: 152,800,1
Nodesize: 112,20
Windstate: 2,287,69,586,548
Paramnames: Y,B,I,K,C,S
Close Multivariate_distrib
Chance Simulated_sp
Title: Simulated sp
Definition: gaussian(Mean_sp, Cov_sp, Stock, Stock2 )
Nodelocation: 448,216,1
Nodesize: 48,24
Valuestate: 2,-22,291,544,348,1,SAMP
Reformval: [Undefined,Undefined,Undefined,Undefined,Undefined,1]
{!40000|Att_xrole: -1}
{!40000|Att_yrole: -3}
{!40000|Att_coordinateindex: Stock}
Close Historical_data
Module Statistical_functio1
Title: Statistical Functions applied to Uncertainty
Defaultsize: 48,24
Nodelocation: 264,56,1
Nodesize: 68,42
Diagstate: 1,353,43,570,438,17
Chance X
Title: X
Definition: LogNormal(mean:5,stddev:3)
Nodelocation: 88,48,1
Nodesize: 48,24
Valuestate: 2,96,29,453,460,1,PDFP
Graphsetup: Statsselect:[1, 1, 1, 1, 1, 1, 1, 1 ]
Variable Mx
Title: mx
Definition: Mean ( X, Run )
Nodelocation: 216,48,1
Nodesize: 48,24
Valuestate: 2,577,447,416,303,0,MIDM
Aliases: Alias Mx1
Variable Sq_x
Title: sq x
Definition: sqrt(x)
Nodelocation: 88,120,1
Nodesize: 48,24
Valuestate: 2,176,300,416,303,0,SAMP
Module Difference_between_m
Title: Difference between Mean & Average
Nodelocation: 448,49,1
Nodesize: 48,42
Variable Ave_x
Title: ave x
Definition: Average(Sample(X),Run)
Nodelocation: 216,48,1
Nodesize: 48,24
Valuestate: 2,100,449,416,303,0,MIDM
Chance A
Title: a
Definition: LogNormal(10,4)
Nodelocation: 96,112,1
Nodesize: 48,24
Valuestate: 2,572,15,416,111,0,MEAN
Chance B
Title: b
Definition: uniform(0,20)
Nodelocation: 96,168,1
Nodesize: 48,24
Valuestate: 2,586,155,416,118,0,MIDM
Variable Ave_ab
Title: ave ab
Definition: Average( [ a,b ] )
Nodelocation: 216,112,1
Nodesize: 48,24
Valuestate: 2,591,311,416,125,0,MIDM
Variable Mean_ab
Title: mean ab
Definition: mean( [a,b] )
Nodelocation: 216,168,1
Nodesize: 48,24
Valuestate: 2,599,470,396,147,0,MIDM
{!40000|Att_previndexvalue: [A,B]}
Alias Mx1
Title: mx
Definition: 1
Nodelocation: 104,56,1
Nodesize: 48,24
Original: Mx
Close Difference_between_m
Variable Sd_x
Title: sd x
Definition: sdeviation(X)
Nodelocation: 216,104,1
Nodesize: 48,24
Variable A75th_percentile
Title: 75th percentile
Definition: getfract(x,0.75)
Nodelocation: 216,160,1
Nodesize: 48,24
Variable Histo_x
Title: histo x
Definition: pdf(X)
Nodelocation: 216,216,1
Nodesize: 48,24
Valuestate: 2,564,27,431,331,1,MIDM
Reformval: [Sys_localindex('STEP'),Densityindex]
{!40000|Att_coordinateindex: Densityindex}
Variable Min_x
Title: min x
Definition: Min(Sample(X),Run)
Nodelocation: 328,104,1
Nodesize: 48,24
Chance Y
Title: Y
Definition: X^2 + Normal(0,10)
Nodelocation: 88,176,1
Nodesize: 48,24
Valuestate: 2,406,50,460,349,1,SAMP
Xyexpr: X
Variable Corr_xy
Title: corr xy
Definition: Correlation(x,y)
Nodelocation: 88,232,1
Nodesize: 48,24
Variable Covariance1
Title: Covariance
Definition: Covariance(x,y)
Nodelocation: 88,288,1
Nodesize: 48,24
Variable Rankcorrel1
Title: rankcorrel(x,y)
Definition: rankcorrel(x,y)
Nodelocation: 88,344,1
Nodesize: 48,24
Variable Med_x
Title: med x
Definition: Median(x)
Nodelocation: 328,160,1
Nodesize: 48,24
Valuestate: 2,84,279,416,303,0,MIDM
Function Median(X : ContextSamp[I] ; I : optional Index = Run)
Title: Median
Definition: getfract(X,0.5, I)
Nodelocation: 456,160,1
Nodesize: 48,24
Windstate: 2,3,367,476,224
Paramnames: X,I
Function Stat_min( X : ContextSamp[I] ; I : Index = Run )
Title: stat min
Definition: min(X,I)
Nodelocation: 456,224,1
Nodesize: 48,24
Windstate: 2,31,370,476,224
Paramnames: X,I
Close Statistical_functio1
Module Discrete_vs__continu
Title: Discrete vs. Continuous
Defaultsize: 48,24
Nodelocation: 88,153,1
Nodesize: 68,42
Diagstate: 1,33,13,550,300,17
Chance Count
Title: Count
Definition: Poisson(100) / 4
Nodelocation: 104,56,1
Nodesize: 48,24
Valuestate: 2,194,74,794,534,1,PDFP
Domain: Domdiscretenumeric
Variable Histo_count
Title: histo count
Definition: Pdf( Count, discrete : False )
Nodelocation: 232,56,1
Nodesize: 48,24
Valuestate: 2,512,160,417,390,1,MIDM
Reformval: [Densityindex,Sys_localindex('STEP')]
{!40000|Att_coordinateindex: Densityindex}
Close Discrete_vs__continu
Module Sample_weighting
Title: Sample weighting
Defaultsize: 48,24
Nodelocation: 256,160,1
Nodesize: 48,24
Diagstate: 1,86,82,550,300,17
Chance U1
Title: U1
Definition: uniform(-1,1)
Nodelocation: 112,64,1
Nodesize: 48,24
Chance U2
Title: U2
Definition: Uniform(-1,1)
Nodelocation: 232,64,1
Nodesize: 48,24
Objective V
Title: V
Definition: (U1+U2) / (abs(U1-U2) + 1 )
Nodelocation: 160,136,1
Nodesize: 48,24
Valuestate: 2,124,7,775,600,1,STAT
Graphsetup: {!40000|Graph_symbolsizekey:1}~
{!40000|Att_contlinestyle Run:4}
Reformval: [Result_type,Result_type,Undefined,Undefined,1,1]
Xyexpr: U1
{!40000|Att_resultslicestate: [Densityindex,1,Result_type,1,Sys_localindex~~
('STEP'),1]}
{!40000|Att_yrole: 2}
{!40000|Att_symbolsizerole: Self}
{!40000|Att_exogenousvalues: [U2]}
Variable Wt
Title: wt
Definition: determTable( Result_type) ( 1, u1<=0 or u2<=0)
Nodelocation: 280,136,1
Nodesize: 48,24
Valuestate: 2,138,71,417,558,0,SAMP
Variable Mv
Title: mv
Definition: mean(V,w:wt)
Nodelocation: 104,200,1
Nodesize: 48,24
Valuestate: 2,42,463,416,303,0,MIDM
Variable Sd_v
Title: sd v
Definition: sdeviation(v, w:wt )
Nodelocation: 232,200,1
Nodesize: 48,24
Valuestate: 2,176,265,416,303,0,MIDM
Decision Result_type
Title: Result type
Definition: Choice( Self, 0 )
Nodelocation: 360,64,1
Nodesize: 48,24
Domain: ['Prior','Posterior']
{!40000|Att_previndexvalue: ['Prior','Posterior']}
Variable Pdf_v
Title: pdf v
Definition: pdf(v, w:wt )
Nodelocation: 352,200,1
Nodesize: 48,24
Valuestate: 2,232,36,742,556,1,MIDM
Reformval: [Sys_localindex('STEP'),Result_type]
{!40000|Att_coordinateindex: Densityindex}
Close Sample_weighting
Close Statistical_function