How to draw the cdf of an exponential random variable in Tikz









up vote
6
down vote

favorite












So the task is to create a TikZ figure of the CDF of an exponential random variable for three different choices of the rate parameter λ and for x between 0 and 5 (using λ = 0.5, λ = 1 and λ = 1.5). The three different CDF’s should be on the same graph and distinguished by colour. The axes should be labelled.



so far I have:



beginfigure[h!]

centering

begintikzpicture [xscale = 1, yscale=1, domain=0:2]

draw[<->](0,0)--(1,0) node[above]$x$;

draw[<->](0,0)--(0,1) node[right]$y$;

draw[color=green, thick] plot(x,1-exp(-x));

endtikzpicture

captionCaption

labelfig:my_label

endfigure


This is returning error messages saying there are too many closing brackets and I am unsure of where to go from here, as I have tried several different changes and none of them have worked.
Thank you!










share|improve this question



























    up vote
    6
    down vote

    favorite












    So the task is to create a TikZ figure of the CDF of an exponential random variable for three different choices of the rate parameter λ and for x between 0 and 5 (using λ = 0.5, λ = 1 and λ = 1.5). The three different CDF’s should be on the same graph and distinguished by colour. The axes should be labelled.



    so far I have:



    beginfigure[h!]

    centering

    begintikzpicture [xscale = 1, yscale=1, domain=0:2]

    draw[<->](0,0)--(1,0) node[above]$x$;

    draw[<->](0,0)--(0,1) node[right]$y$;

    draw[color=green, thick] plot(x,1-exp(-x));

    endtikzpicture

    captionCaption

    labelfig:my_label

    endfigure


    This is returning error messages saying there are too many closing brackets and I am unsure of where to go from here, as I have tried several different changes and none of them have worked.
    Thank you!










    share|improve this question

























      up vote
      6
      down vote

      favorite









      up vote
      6
      down vote

      favorite











      So the task is to create a TikZ figure of the CDF of an exponential random variable for three different choices of the rate parameter λ and for x between 0 and 5 (using λ = 0.5, λ = 1 and λ = 1.5). The three different CDF’s should be on the same graph and distinguished by colour. The axes should be labelled.



      so far I have:



      beginfigure[h!]

      centering

      begintikzpicture [xscale = 1, yscale=1, domain=0:2]

      draw[<->](0,0)--(1,0) node[above]$x$;

      draw[<->](0,0)--(0,1) node[right]$y$;

      draw[color=green, thick] plot(x,1-exp(-x));

      endtikzpicture

      captionCaption

      labelfig:my_label

      endfigure


      This is returning error messages saying there are too many closing brackets and I am unsure of where to go from here, as I have tried several different changes and none of them have worked.
      Thank you!










      share|improve this question















      So the task is to create a TikZ figure of the CDF of an exponential random variable for three different choices of the rate parameter λ and for x between 0 and 5 (using λ = 0.5, λ = 1 and λ = 1.5). The three different CDF’s should be on the same graph and distinguished by colour. The axes should be labelled.



      so far I have:



      beginfigure[h!]

      centering

      begintikzpicture [xscale = 1, yscale=1, domain=0:2]

      draw[<->](0,0)--(1,0) node[above]$x$;

      draw[<->](0,0)--(0,1) node[right]$y$;

      draw[color=green, thick] plot(x,1-exp(-x));

      endtikzpicture

      captionCaption

      labelfig:my_label

      endfigure


      This is returning error messages saying there are too many closing brackets and I am unsure of where to go from here, as I have tried several different changes and none of them have worked.
      Thank you!







      tikz-pgf floats






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 21:00









      AndréC

      6,32711140




      6,32711140










      asked Nov 9 at 20:42









      ScarW

      311




      311




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          This is because mathematical functions with tikz are not written like LaTeX macros. They are written without the reverse bar



          All you have to do is write:



          draw[color=green, thick] plot(x,1-exp(-x));


          graphe



          documentclass[12pt]article
          usepackagetikz

          begindocument
          begintikzpicture [xscale = 1, yscale=1, domain=0:2]
          draw[<->](0,0)--(1,0) node[above]$x$;
          draw[<->](0,0)--(0,1) node[right]$y$;
          draw[color=green, thick] plot(x,1-exp(-x));
          endtikzpicture
          enddocument





          share|improve this answer


















          • 1




            Good catch!!!!!
            – marmot
            Nov 9 at 20:57










          • @marmot thanks you !!! :)
            – AndréC
            Nov 9 at 20:58


















          up vote
          3
          down vote













          AndréC already told you what's causing the error. But from your title I am wondering if you are looking for something like the following.



          documentclassarticle
          usepackagetikz

          begindocument
          beginfigure[h!]

          centering

          begintikzpicture [xscale = 1, yscale=1, domain=0:6]
          draw[latex-latex](0,2.2) node[left]$y$ |- (6.2,0) node[below]$x$;
          foreach X/Col in 0.5/green!60!black,1/blue,2/red
          draw[color=Col, thick] plot[variable=x,smooth] (x,1-tanh(X*(3-x)));
          endtikzpicture
          captionCaption
          labelfig:my_label
          endfigure
          enddocument


          enter image description here






          share|improve this answer




















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "85"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459203%2fhow-to-draw-the-cdf-of-an-exponential-random-variable-in-tikz%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            This is because mathematical functions with tikz are not written like LaTeX macros. They are written without the reverse bar



            All you have to do is write:



            draw[color=green, thick] plot(x,1-exp(-x));


            graphe



            documentclass[12pt]article
            usepackagetikz

            begindocument
            begintikzpicture [xscale = 1, yscale=1, domain=0:2]
            draw[<->](0,0)--(1,0) node[above]$x$;
            draw[<->](0,0)--(0,1) node[right]$y$;
            draw[color=green, thick] plot(x,1-exp(-x));
            endtikzpicture
            enddocument





            share|improve this answer


















            • 1




              Good catch!!!!!
              – marmot
              Nov 9 at 20:57










            • @marmot thanks you !!! :)
              – AndréC
              Nov 9 at 20:58















            up vote
            3
            down vote













            This is because mathematical functions with tikz are not written like LaTeX macros. They are written without the reverse bar



            All you have to do is write:



            draw[color=green, thick] plot(x,1-exp(-x));


            graphe



            documentclass[12pt]article
            usepackagetikz

            begindocument
            begintikzpicture [xscale = 1, yscale=1, domain=0:2]
            draw[<->](0,0)--(1,0) node[above]$x$;
            draw[<->](0,0)--(0,1) node[right]$y$;
            draw[color=green, thick] plot(x,1-exp(-x));
            endtikzpicture
            enddocument





            share|improve this answer


















            • 1




              Good catch!!!!!
              – marmot
              Nov 9 at 20:57










            • @marmot thanks you !!! :)
              – AndréC
              Nov 9 at 20:58













            up vote
            3
            down vote










            up vote
            3
            down vote









            This is because mathematical functions with tikz are not written like LaTeX macros. They are written without the reverse bar



            All you have to do is write:



            draw[color=green, thick] plot(x,1-exp(-x));


            graphe



            documentclass[12pt]article
            usepackagetikz

            begindocument
            begintikzpicture [xscale = 1, yscale=1, domain=0:2]
            draw[<->](0,0)--(1,0) node[above]$x$;
            draw[<->](0,0)--(0,1) node[right]$y$;
            draw[color=green, thick] plot(x,1-exp(-x));
            endtikzpicture
            enddocument





            share|improve this answer














            This is because mathematical functions with tikz are not written like LaTeX macros. They are written without the reverse bar



            All you have to do is write:



            draw[color=green, thick] plot(x,1-exp(-x));


            graphe



            documentclass[12pt]article
            usepackagetikz

            begindocument
            begintikzpicture [xscale = 1, yscale=1, domain=0:2]
            draw[<->](0,0)--(1,0) node[above]$x$;
            draw[<->](0,0)--(0,1) node[right]$y$;
            draw[color=green, thick] plot(x,1-exp(-x));
            endtikzpicture
            enddocument






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 at 20:59

























            answered Nov 9 at 20:56









            AndréC

            6,32711140




            6,32711140







            • 1




              Good catch!!!!!
              – marmot
              Nov 9 at 20:57










            • @marmot thanks you !!! :)
              – AndréC
              Nov 9 at 20:58













            • 1




              Good catch!!!!!
              – marmot
              Nov 9 at 20:57










            • @marmot thanks you !!! :)
              – AndréC
              Nov 9 at 20:58








            1




            1




            Good catch!!!!!
            – marmot
            Nov 9 at 20:57




            Good catch!!!!!
            – marmot
            Nov 9 at 20:57












            @marmot thanks you !!! :)
            – AndréC
            Nov 9 at 20:58





            @marmot thanks you !!! :)
            – AndréC
            Nov 9 at 20:58











            up vote
            3
            down vote













            AndréC already told you what's causing the error. But from your title I am wondering if you are looking for something like the following.



            documentclassarticle
            usepackagetikz

            begindocument
            beginfigure[h!]

            centering

            begintikzpicture [xscale = 1, yscale=1, domain=0:6]
            draw[latex-latex](0,2.2) node[left]$y$ |- (6.2,0) node[below]$x$;
            foreach X/Col in 0.5/green!60!black,1/blue,2/red
            draw[color=Col, thick] plot[variable=x,smooth] (x,1-tanh(X*(3-x)));
            endtikzpicture
            captionCaption
            labelfig:my_label
            endfigure
            enddocument


            enter image description here






            share|improve this answer
























              up vote
              3
              down vote













              AndréC already told you what's causing the error. But from your title I am wondering if you are looking for something like the following.



              documentclassarticle
              usepackagetikz

              begindocument
              beginfigure[h!]

              centering

              begintikzpicture [xscale = 1, yscale=1, domain=0:6]
              draw[latex-latex](0,2.2) node[left]$y$ |- (6.2,0) node[below]$x$;
              foreach X/Col in 0.5/green!60!black,1/blue,2/red
              draw[color=Col, thick] plot[variable=x,smooth] (x,1-tanh(X*(3-x)));
              endtikzpicture
              captionCaption
              labelfig:my_label
              endfigure
              enddocument


              enter image description here






              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                AndréC already told you what's causing the error. But from your title I am wondering if you are looking for something like the following.



                documentclassarticle
                usepackagetikz

                begindocument
                beginfigure[h!]

                centering

                begintikzpicture [xscale = 1, yscale=1, domain=0:6]
                draw[latex-latex](0,2.2) node[left]$y$ |- (6.2,0) node[below]$x$;
                foreach X/Col in 0.5/green!60!black,1/blue,2/red
                draw[color=Col, thick] plot[variable=x,smooth] (x,1-tanh(X*(3-x)));
                endtikzpicture
                captionCaption
                labelfig:my_label
                endfigure
                enddocument


                enter image description here






                share|improve this answer












                AndréC already told you what's causing the error. But from your title I am wondering if you are looking for something like the following.



                documentclassarticle
                usepackagetikz

                begindocument
                beginfigure[h!]

                centering

                begintikzpicture [xscale = 1, yscale=1, domain=0:6]
                draw[latex-latex](0,2.2) node[left]$y$ |- (6.2,0) node[below]$x$;
                foreach X/Col in 0.5/green!60!black,1/blue,2/red
                draw[color=Col, thick] plot[variable=x,smooth] (x,1-tanh(X*(3-x)));
                endtikzpicture
                captionCaption
                labelfig:my_label
                endfigure
                enddocument


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 23:20









                marmot

                78.8k487166




                78.8k487166



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459203%2fhow-to-draw-the-cdf-of-an-exponential-random-variable-in-tikz%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Syphilis

                    Darth Vader #20