<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Triangular distribution function in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066417#M87485</link>
    <description>&lt;P&gt;maybe helpful:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarcoWedel_0-1682970136359.png" style="width: 761px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/106189iBDB925A15909108A/image-dimensions/761x493?v=v2" width="761" height="493" role="button" title="MarcoWedel_0-1682970136359.png" alt="MarcoWedel_0-1682970136359.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LET a = 1;
LET b = 4;
LET c = 3;
LET Fc = (c-a)/(b-a);
SET X = If($1&amp;lt;$(Fc),$(a)+sqrt($1*($(b)-$(a))*($(c)-$(a))),$(b)-sqrt((1-$1)*($(b)-$(a))*($(b)-$(c))));

table1:
LOAD *,
     $(X(U)) as x;
LOAD RecNo() as ID,
     Rand() as U
AutoGenerate 10000000;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2023 19:43:07 GMT</pubDate>
    <dc:creator>MarcoWedel</dc:creator>
    <dc:date>2023-05-01T19:43:07Z</dc:date>
    <item>
      <title>Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066003#M87461</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am looking for a way to draw values from a triangular distribution function. However, such function does not exist in the &lt;A href="https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/StatisticalDistributionFunctions/statistical-distribution-functions.htm?_ga=2.60060845.1816609180.1682707186-285361954.1671550862" target="_self"&gt;statistical functions available in Qlik Sense&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;I thought of coding the function myself, but I am facing difficulty writing it.&lt;/P&gt;
&lt;P&gt;The idea was to have a function (e.g. TriangDraw) that requires the Lowest bound, Mode and Highest bound of the triangle as input.&lt;/P&gt;
&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 22:13:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066003#M87461</guid>
      <dc:creator>FlyingFrog</dc:creator>
      <dc:date>2023-04-28T22:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066004#M87462</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6622"&gt;@hic&lt;/a&gt;&amp;nbsp; As I saw your &lt;A href="https://community.qlik.com/t5/Design/Monte-Carlo-Methods/ba-p/1472458" target="_self"&gt;post&lt;/A&gt; on monte carlo methods in QLik, possibly you know an answer to this.&lt;BR /&gt;Once the function is completed I am aiming to code monte carlo simulations for risk management and visualize results in Qlik sense :).&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 22:16:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066004#M87462</guid>
      <dc:creator>FlyingFrog</dc:creator>
      <dc:date>2023-04-28T22:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066033#M87467</link>
      <description>&lt;P&gt;I have no experience in this, but I found these expressions on Wikipedia:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hic_0-1682758383861.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/106094i01F057EDFA863A50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hic_0-1682758383861.png" alt="hic_0-1682758383861.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I think you can create what you need from this. U is the same as the Qlik Rand() function. a/b are lower/upper bounds and c is the mode.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Triangular_distribution" target="_blank"&gt;https://en.wikipedia.org/wiki/Triangular_distribution&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2023 08:55:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066033#M87467</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2023-04-29T08:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066279#M87477</link>
      <description>&lt;P&gt;Hi Hic,&lt;BR /&gt;&lt;BR /&gt;Thank you I will further explore. Will post my solution here if succesful.&lt;BR /&gt;&lt;BR /&gt;If anyone else still able to assist -&amp;gt; thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 09:46:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066279#M87477</guid>
      <dc:creator>FlyingFrog</dc:creator>
      <dc:date>2023-05-01T09:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066417#M87485</link>
      <description>&lt;P&gt;maybe helpful:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarcoWedel_0-1682970136359.png" style="width: 761px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/106189iBDB925A15909108A/image-dimensions/761x493?v=v2" width="761" height="493" role="button" title="MarcoWedel_0-1682970136359.png" alt="MarcoWedel_0-1682970136359.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LET a = 1;
LET b = 4;
LET c = 3;
LET Fc = (c-a)/(b-a);
SET X = If($1&amp;lt;$(Fc),$(a)+sqrt($1*($(b)-$(a))*($(c)-$(a))),$(b)-sqrt((1-$1)*($(b)-$(a))*($(b)-$(c))));

table1:
LOAD *,
     $(X(U)) as x;
LOAD RecNo() as ID,
     Rand() as U
AutoGenerate 10000000;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 19:43:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066417#M87485</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2023-05-01T19:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066604#M87503</link>
      <description>&lt;P&gt;Thank you Marco!&lt;/P&gt;
&lt;P&gt;Was getting to something similar, but I think your code runs faster and will be more feasible to applying X to a table with a number of e.g. 10 different triangular distribution characteristics.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Lets see what today is going to bring me to :)!&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 09:24:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066604#M87503</guid>
      <dc:creator>FlyingFrog</dc:creator>
      <dc:date>2023-05-02T09:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Triangular distribution function</title>
      <link>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066702#M87513</link>
      <description>&lt;P&gt;For those looking for a similar solution to iterate similar items to perform e.g. a monte carlo simulation on a number of triangular distributions one can use the following code:&lt;/P&gt;
&lt;PRE&gt;Let Iteration = 10000;&lt;BR /&gt;&lt;BR /&gt;//Create a table with a number of distribution characteristics&lt;BR /&gt;ExampleDist:&lt;BR /&gt;LOAD * inline&amp;nbsp;&lt;BR /&gt;[&lt;BR /&gt;ID,a,b,c,Prob&lt;BR /&gt;123,100,800,200,0.5&lt;BR /&gt;124,50,600,500,0.3&lt;BR /&gt;125,600,800,700,0.8&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;// Loop through each row of the ExampleRisks table&lt;BR /&gt;FOR i = 0 to NoOfRows('ExampleDist')-1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LET a = Peek('a', i, 'ExampleDist');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LET b = Peek('b', i, 'ExampleDist');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LET c = Peek('c', i, 'ExampleDist');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LET ID = Peek('ID', i, 'ExampleDist');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LET Prob = Peek('Prob', i, 'ExampleDist');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; SET Fc = ($(c)-$(a))/($(b)-$(a));&lt;BR /&gt;SET X = If($1&amp;lt;$(Fc),$(a)+sqrt($1*($(b)-$(a))*($(c)-$(a))),$(b)-sqrt((1-$1)*($(b)-$(a))*($(b)-$(c))));&lt;BR /&gt;&lt;BR /&gt;//Store &lt;BR /&gt;&amp;nbsp;Samples:&lt;BR /&gt;LOAD *,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; $(ID) as ID,&lt;BR /&gt;$(Prob) &amp;gt; Rand() as occured,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $(X(U)) as x;&lt;BR /&gt;LOAD RecNo() as Line,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Rand() as U&lt;BR /&gt;AutoGenerate $(Iteration);&lt;BR /&gt;&lt;BR /&gt;NEXT i&lt;BR /&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;All drawn values in one figure:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FlyingFrog_0-1683029629698.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/106255iE7846A056AFA5E50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FlyingFrog_0-1683029629698.png" alt="FlyingFrog_0-1683029629698.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 12:14:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Triangular-distribution-function/m-p/2066702#M87513</guid>
      <dc:creator>FlyingFrog</dc:creator>
      <dc:date>2023-05-02T12:14:50Z</dc:date>
    </item>
  </channel>
</rss>

