{ From user Lonnie, Model Delaunay_from_python at 1-Aug-2018 5:32:51 PM, encoding="UTF-8" } SoftwareVersion 5.2.0 { System Variables with non-default values: } SampleSize := 1000 TypeChecking := 1 Checking := 1 SaveOptions := 2 SaveValues := 0 NodeInfo FormNode: 1,0,0,1,0,0,0,,0,0,,0,0 Model Delaunay_from_python Description: This example demonstrates how an Analytica model can call methods in Python (Python is a programming language) using COM. This example is from the artilce~ ~ • Calling Python code ~ ~ that appears on the Analytica wiki. In this example, a Delaunay tessellation, aka Delaunay triangulation, is computed for a random set of 2-D points. I Delaunay tessellation is a set of adjacent and non-overlapping triangles, using the points as vertices, such that any circle that contains the points of a triangle does not contain any other point in its interior. Author: Lonnie Chrisman, Ph.D.~ Lumina Decision Systems Date: Wed, Aug 1, 2018 9:25 AM SaveAuthor: Lonnie SaveDate: Wed, Aug 1, 2018 5:32 PM DiagState: 2,1,0,773,545,17 WindState: 2,412,462,720,350 FontStyle: Arial,15 FileInfo: 0,Model Delaunay_from_python,2,2,0,0,C:\Users\Lonnie\Documents\Analytica\Analytica_Python\Delaunay from python.ana Variable py Title: py Definition: COMCreateObject("Lumina.DelaunayCOM") NodeLocation: 160,80,1 NodeSize: 48,24 Button Pause Title: Pause NodeLocation: 160,176,1 NodeSize: 48,24 OnClick: py->Pause() Index Pt Title: Pt Description: The point number. Indexes the data points. Definition: 1..10 NodeLocation: 312,80,1 NodeSize: 48,24 WindState: 2,389,524,720,350 Index Dim Title: Dim Description: Points in this example are 2-D. Indexes the point dimensions. I.e., Dim=1 is the point's first dimension, Dim=2 is the 2nd dimension. Definition: [1,2] NodeLocation: 424,80,1 NodeSize: 48,24 WindState: 2,408,498,720,350 Att_PrevIndexValue: [1,2] Variable pts Title: pts Description: A random set of 2-D points that will be used. Definition: Random( Binormal( Array(Dim,[1,2]), Array(Dim,[2,1]), Dim, 0.5, over:Pt ) ) NodeLocation: 312,168,1 NodeSize: 48,24 WindState: 2,501,586,720,350 ValueState: 2,6,315,634,576,1,MIDM G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aVSPNNNOQSWbgnu09KVht5KZq5Og$Kg1OnBb0SvNsMtPxV3fFrT6mR6pWF_lWH4tiYOG81xtpmjiiijmpty29HPZjv5IWl$GXq8Sn7UsFf4VyQuNuPxU2cCoQ2hM1jQ8scM8wjXMD4xqkeaVTQPPQSVYdiow2BKVhu5KZp5NfzHd_Lk7XzOrJoHoKsP_Z8mN0gK$iP7scN9xlZPF6$uniebYXWWXadhlry3CLWhs3HWm1IbuCXtEc$OpEh8c5b6eAkIuU6kN1iO4oXG0nZMB$riZSLGB742111368DIOVdmw4GSft6MdvBVq9WtFe2TvLpHnHoLuS1cDrT7nS8rZI2oaMA_pfVNG94$yvustuvy$39FMUeoz8LZn1GXp6Ql5SpCb0RtJmGlGnKtS1dEsU7nS8rYH0nZMA_qgYQJD83$ywvuvx_27DJRaju3FSft6MdvCWrBYwJj7Z0TxQwQxT0a9lM_dHyeL3nXI3rdQF4wnfYSNJGEDDEGIMQVahow3EOan0FVm2LfzJf1OnAb0SvNsMtPzX6iIwZCtXDvdL4qbNA$qgXPIC73$ywvuuwy$38EMUdny8LZo1IYq7Qk4Qn9YyNqHlEkFnJtQ$bBoR4kP5pWG0nZMA$qfWOHA50yv} 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 functions in this library. A Mid value from a distribution function will therefore be indexed by I, whlie a Sample from a distribution function is indexed by both I and Run. These distribution functions can also 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 distributions. Correlate_with, for example, allows you to generate a univarite 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, where 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: Wed, May 10, 2017 3:31 PM DefaultSize: 48,24 NodeLocation: 640,64,1 NodeSize: 64,24 NodeInfo: 1,1,1,1,1,1,0,0,0,0,,,,0 DiagState: 2,15,10,743,821,17 WindState: 2,401,199,776,387 FontStyle: Arial, 15 Att_PreLoadScript: {!40404|FreePassObjectCount 86sQq6qJq4RNUM0tPBWqCVgcLOsQ2PZu9SyrmK$cu3RVdU8zkXgw6NLRRBxazLn8X2yvd9g9RsJsqnfU8WzaSmryodN$Tj2X7DGDtYyZrNSWehdciIrISdXeQSKuXuTRccTNEwc9Ugz1vfUTjPsLZt_wjZM_les9OOCunLoWwMZomwvTC$9LdsxpZPGiJhr662FpP5kDVfv6D1sQBhBa5t5452aH1aoJiMSJC1R0e39ZqMK3qXpGm31KTueLt7Sww030gLAGo5QUfPK0U9V5JWjbaPxo0GckqvkUR$hQYt1DNB6gLtaYy7KGB1qSoDoewz23fQEr7lCnlnkiRtRkq31GmiP8p3UyD9SZygLr3Mo0wxjHwi0Qn20$8ZJ0Yo7bZUJ70eNlNbu2JskZDb2em_473$kDzJk0PwqohbHf8OQXnZRG$RuVEMYfnP_TxUm9BTLI6yf4jUes$9rdHuOuBEYSRH9uL0yKTelRICvH1aTTPQ8_kEk7QegmYb_UwRf$FFF8pR8hAWZwYcRIubtKqjhzBEYIpMe1$8KvZYWFFhu75AqfXo8pUvbjcXByIpNKMky3RFqR_6PluipwtnXCoJl_UQ7sXnCgxt7GPRMD$cBYAE3wj5eEdh4SkvvqgT7cMYVUPvaIp$X1QfrvwndIpbpopmI$lIW5d_JVdfYP6fTjknmK3rQgIsJcs_3_udC2KNST3qer7iHi4KVYYTDqi05CFtgWl3hJmBThoqjaD7TajoSH9QmR0VzKYklmbGCaju$hYSl7rY2Yt7HLJAtrFQdmUNJe2pR2VvBQZWM5$7ThphL61vmS1Y0Pfk50OGtEb_NoDf6a3Y3b7gFqQ1fIxcI_hP9vfRE2siYQIB50yusrqqsux$4AGOWgq0CPcr5MdwDXtCZxKk9a0UyRxS_X5fFrT5kO3lR9tdN9xkYND4xqjeZVSQPPQRUXchnu09JTfs3HWn1JcwEawIg3TuKnFjDjEnKuT2fHvZDvbI0lVG2qeSH7_slfaVSPNNNOQSWbgnu09KVht5KZq5Og$Kg1OnBb0SvNsMtPxV3fFrT6mR6pWF_lWH4tiYOG81xtpmjiiijmpty29HPZjv5IWl$GXq8Sn7UsFf4VyQuNuPxU2cCoQ2hM1jQ8scM8wjXMD4xqkeaVTQPPQSVYdiow2BKVhu5KZp5NfzHd_Lk7XzOrJoHoKsP_Z8mN0gK$iP7scN9xlZPF6$uniebYXWWXadhlry3CLWhs3HWm1IbuCXtEc$OpEh8c5b6eAkIuU6kN1iO4oXG0nZMB$riZSLGB742111368DIOVdmw4GSft6MdvBVq9WtFe2TvLpHnHoLuS1cDrT7nS8rZI2oaMA_pfVNG94$yvustuvy$39FMUeoz8LZn1GXp6Ql5SpCb0RtJmGlGnKtS1dEsU7nS8rYH0nZMA_qgYQJD83$ywvuvx_27DJRaju3FSft6MdvCWrBYwJj7Z0TxQwQxT0a9lM_dHyeL3nXI3rdQF4wnfYSNJGEDDEGIMQVahow3EOan0FVm2LfzJf1OnAb0SvNsMtPzX6iIwZCtXDvdL4qbNA$qgXPIC73$ywvuuwy$38EMUdny8LZo1IYq7Qk4Qn9YyNqHlEkFnJtQ$bBoR4kP5pWG0nZMA$qfWOHA50yv} {!40400|Att_clearTypeFonts: -1} 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) distribution, 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 matrix. ~ ~ 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 ignoring sampling error. That may be insignificant of N is large. Otherwise, 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, after having computed the sample covariance matrix (assumed to be drawn, by nature, from a Wishart), is also an InvertedWishart. Definition: var T := if i