SmoothHistogram as “Probability”?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












In a previous post, the following answer was given:



ClearAll[dist] 
dist[α_?NumericQ, β_?NumericQ] :=
TransformedDistribution[0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 x^2],
Distributed[x, TruncatedDistribution[0, 0.02135225, GammaDistribution[α, β]]]]


and



H = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000]


did indeed provide what I was looking for. Except the last step. The last step is to use SmoothHistogram on $H$ and present the data in terms of "Probability". However, reading up on SmoothHistogram, "PDF", "CF" and so on are options, but not "Probability".



So, how can I show the output of SmoothHistogram as "Probability"?










share|improve this question























  • I am not sure what probability would even mean in this case ... A histogram is discrete. It has bins. It makes sense to ask the probability that a data point falls in a certain bin. SmoothHistogram is inherently continuous, thus probability makes no sense. Only probability density does. Voting to close as the question is due to a mathematical misunderstanding.
    – Szabolcs
    4 hours ago










  • That is true. My problem is that I have a Histogram (as you say, discrete) that I would like to overlay with the smooth curve given by $dist$ where probability is on the y axis. Thinking about what you say, I guess that is not possible.
    – user120911
    4 hours ago






  • 1




    Instead of using SmoothHistogram, you could compute a SmoothKernelDistribution, then Plot the PDF of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
    – Szabolcs
    4 hours ago















up vote
1
down vote

favorite












In a previous post, the following answer was given:



ClearAll[dist] 
dist[α_?NumericQ, β_?NumericQ] :=
TransformedDistribution[0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 x^2],
Distributed[x, TruncatedDistribution[0, 0.02135225, GammaDistribution[α, β]]]]


and



H = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000]


did indeed provide what I was looking for. Except the last step. The last step is to use SmoothHistogram on $H$ and present the data in terms of "Probability". However, reading up on SmoothHistogram, "PDF", "CF" and so on are options, but not "Probability".



So, how can I show the output of SmoothHistogram as "Probability"?










share|improve this question























  • I am not sure what probability would even mean in this case ... A histogram is discrete. It has bins. It makes sense to ask the probability that a data point falls in a certain bin. SmoothHistogram is inherently continuous, thus probability makes no sense. Only probability density does. Voting to close as the question is due to a mathematical misunderstanding.
    – Szabolcs
    4 hours ago










  • That is true. My problem is that I have a Histogram (as you say, discrete) that I would like to overlay with the smooth curve given by $dist$ where probability is on the y axis. Thinking about what you say, I guess that is not possible.
    – user120911
    4 hours ago






  • 1




    Instead of using SmoothHistogram, you could compute a SmoothKernelDistribution, then Plot the PDF of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
    – Szabolcs
    4 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











In a previous post, the following answer was given:



ClearAll[dist] 
dist[α_?NumericQ, β_?NumericQ] :=
TransformedDistribution[0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 x^2],
Distributed[x, TruncatedDistribution[0, 0.02135225, GammaDistribution[α, β]]]]


and



H = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000]


did indeed provide what I was looking for. Except the last step. The last step is to use SmoothHistogram on $H$ and present the data in terms of "Probability". However, reading up on SmoothHistogram, "PDF", "CF" and so on are options, but not "Probability".



So, how can I show the output of SmoothHistogram as "Probability"?










share|improve this question















In a previous post, the following answer was given:



ClearAll[dist] 
dist[α_?NumericQ, β_?NumericQ] :=
TransformedDistribution[0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 x^2],
Distributed[x, TruncatedDistribution[0, 0.02135225, GammaDistribution[α, β]]]]


and



H = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000]


did indeed provide what I was looking for. Except the last step. The last step is to use SmoothHistogram on $H$ and present the data in terms of "Probability". However, reading up on SmoothHistogram, "PDF", "CF" and so on are options, but not "Probability".



So, how can I show the output of SmoothHistogram as "Probability"?







probability-or-statistics






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









kglr

164k8188388




164k8188388










asked 5 hours ago









user120911

41117




41117











  • I am not sure what probability would even mean in this case ... A histogram is discrete. It has bins. It makes sense to ask the probability that a data point falls in a certain bin. SmoothHistogram is inherently continuous, thus probability makes no sense. Only probability density does. Voting to close as the question is due to a mathematical misunderstanding.
    – Szabolcs
    4 hours ago










  • That is true. My problem is that I have a Histogram (as you say, discrete) that I would like to overlay with the smooth curve given by $dist$ where probability is on the y axis. Thinking about what you say, I guess that is not possible.
    – user120911
    4 hours ago






  • 1




    Instead of using SmoothHistogram, you could compute a SmoothKernelDistribution, then Plot the PDF of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
    – Szabolcs
    4 hours ago

















  • I am not sure what probability would even mean in this case ... A histogram is discrete. It has bins. It makes sense to ask the probability that a data point falls in a certain bin. SmoothHistogram is inherently continuous, thus probability makes no sense. Only probability density does. Voting to close as the question is due to a mathematical misunderstanding.
    – Szabolcs
    4 hours ago










  • That is true. My problem is that I have a Histogram (as you say, discrete) that I would like to overlay with the smooth curve given by $dist$ where probability is on the y axis. Thinking about what you say, I guess that is not possible.
    – user120911
    4 hours ago






  • 1




    Instead of using SmoothHistogram, you could compute a SmoothKernelDistribution, then Plot the PDF of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
    – Szabolcs
    4 hours ago
















I am not sure what probability would even mean in this case ... A histogram is discrete. It has bins. It makes sense to ask the probability that a data point falls in a certain bin. SmoothHistogram is inherently continuous, thus probability makes no sense. Only probability density does. Voting to close as the question is due to a mathematical misunderstanding.
– Szabolcs
4 hours ago




I am not sure what probability would even mean in this case ... A histogram is discrete. It has bins. It makes sense to ask the probability that a data point falls in a certain bin. SmoothHistogram is inherently continuous, thus probability makes no sense. Only probability density does. Voting to close as the question is due to a mathematical misunderstanding.
– Szabolcs
4 hours ago












That is true. My problem is that I have a Histogram (as you say, discrete) that I would like to overlay with the smooth curve given by $dist$ where probability is on the y axis. Thinking about what you say, I guess that is not possible.
– user120911
4 hours ago




That is true. My problem is that I have a Histogram (as you say, discrete) that I would like to overlay with the smooth curve given by $dist$ where probability is on the y axis. Thinking about what you say, I guess that is not possible.
– user120911
4 hours ago




1




1




Instead of using SmoothHistogram, you could compute a SmoothKernelDistribution, then Plot the PDF of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
– Szabolcs
4 hours ago





Instead of using SmoothHistogram, you could compute a SmoothKernelDistribution, then Plot the PDF of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
– Szabolcs
4 hours ago











1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










We can use "PDF" as the third argument for both Histogram and SmoothHistogram and then rescale the vertical axis to "Probability" values:



SeedRandom[1]
data = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000];
colors = LightBlue, Green;
hist1, hist2 = Histogram[data, Automatic, #,
ChartStyle -> Last[colors = RotateRight[colors]], PlotLabel -> #,
PerformanceGoal -> "Speed"] & /@ "PDF", "Probability";
shist = SmoothHistogram[data, Automatic, "PDF", PlotStyle -> Directive[Thick, Red]];


Row[Show[hist1, ImageSize -> 300], Show[hist1, shist, ImageSize -> 300]]


enter image description here



We first find the scaling factor using the maximum heights in hist1 and hist2:



scale = Divide @@ (Max[Cases[#[[1]], Rectangle[_, _, _, h_, ___] :> h, ∞]] & /@ 
hist2, hist1);


Since the scaling of the vertical axis is linear, we can simply re-scale the tick labels using Charting`FindTicks:



Row[Show[hist2, ImageSize -> 300], 
Show[hist1, shist, Ticks -> Automatic, Charting`FindTicks[0, 1/scale, 0, 1],
PlotLabel -> "Probability", ImageSize -> 300]]


enter image description here



 






share|improve this answer




















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    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: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183326%2fsmoothhistogram-as-probability%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    We can use "PDF" as the third argument for both Histogram and SmoothHistogram and then rescale the vertical axis to "Probability" values:



    SeedRandom[1]
    data = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000];
    colors = LightBlue, Green;
    hist1, hist2 = Histogram[data, Automatic, #,
    ChartStyle -> Last[colors = RotateRight[colors]], PlotLabel -> #,
    PerformanceGoal -> "Speed"] & /@ "PDF", "Probability";
    shist = SmoothHistogram[data, Automatic, "PDF", PlotStyle -> Directive[Thick, Red]];


    Row[Show[hist1, ImageSize -> 300], Show[hist1, shist, ImageSize -> 300]]


    enter image description here



    We first find the scaling factor using the maximum heights in hist1 and hist2:



    scale = Divide @@ (Max[Cases[#[[1]], Rectangle[_, _, _, h_, ___] :> h, ∞]] & /@ 
    hist2, hist1);


    Since the scaling of the vertical axis is linear, we can simply re-scale the tick labels using Charting`FindTicks:



    Row[Show[hist2, ImageSize -> 300], 
    Show[hist1, shist, Ticks -> Automatic, Charting`FindTicks[0, 1/scale, 0, 1],
    PlotLabel -> "Probability", ImageSize -> 300]]


    enter image description here



     






    share|improve this answer
























      up vote
      3
      down vote



      accepted










      We can use "PDF" as the third argument for both Histogram and SmoothHistogram and then rescale the vertical axis to "Probability" values:



      SeedRandom[1]
      data = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000];
      colors = LightBlue, Green;
      hist1, hist2 = Histogram[data, Automatic, #,
      ChartStyle -> Last[colors = RotateRight[colors]], PlotLabel -> #,
      PerformanceGoal -> "Speed"] & /@ "PDF", "Probability";
      shist = SmoothHistogram[data, Automatic, "PDF", PlotStyle -> Directive[Thick, Red]];


      Row[Show[hist1, ImageSize -> 300], Show[hist1, shist, ImageSize -> 300]]


      enter image description here



      We first find the scaling factor using the maximum heights in hist1 and hist2:



      scale = Divide @@ (Max[Cases[#[[1]], Rectangle[_, _, _, h_, ___] :> h, ∞]] & /@ 
      hist2, hist1);


      Since the scaling of the vertical axis is linear, we can simply re-scale the tick labels using Charting`FindTicks:



      Row[Show[hist2, ImageSize -> 300], 
      Show[hist1, shist, Ticks -> Automatic, Charting`FindTicks[0, 1/scale, 0, 1],
      PlotLabel -> "Probability", ImageSize -> 300]]


      enter image description here



       






      share|improve this answer






















        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        We can use "PDF" as the third argument for both Histogram and SmoothHistogram and then rescale the vertical axis to "Probability" values:



        SeedRandom[1]
        data = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000];
        colors = LightBlue, Green;
        hist1, hist2 = Histogram[data, Automatic, #,
        ChartStyle -> Last[colors = RotateRight[colors]], PlotLabel -> #,
        PerformanceGoal -> "Speed"] & /@ "PDF", "Probability";
        shist = SmoothHistogram[data, Automatic, "PDF", PlotStyle -> Directive[Thick, Red]];


        Row[Show[hist1, ImageSize -> 300], Show[hist1, shist, ImageSize -> 300]]


        enter image description here



        We first find the scaling factor using the maximum heights in hist1 and hist2:



        scale = Divide @@ (Max[Cases[#[[1]], Rectangle[_, _, _, h_, ___] :> h, ∞]] & /@ 
        hist2, hist1);


        Since the scaling of the vertical axis is linear, we can simply re-scale the tick labels using Charting`FindTicks:



        Row[Show[hist2, ImageSize -> 300], 
        Show[hist1, shist, Ticks -> Automatic, Charting`FindTicks[0, 1/scale, 0, 1],
        PlotLabel -> "Probability", ImageSize -> 300]]


        enter image description here



         






        share|improve this answer












        We can use "PDF" as the third argument for both Histogram and SmoothHistogram and then rescale the vertical axis to "Probability" values:



        SeedRandom[1]
        data = RandomVariate[dist[7.788017927062043, 0.0011475109935367525], 5000];
        colors = LightBlue, Green;
        hist1, hist2 = Histogram[data, Automatic, #,
        ChartStyle -> Last[colors = RotateRight[colors]], PlotLabel -> #,
        PerformanceGoal -> "Speed"] & /@ "PDF", "Probability";
        shist = SmoothHistogram[data, Automatic, "PDF", PlotStyle -> Directive[Thick, Red]];


        Row[Show[hist1, ImageSize -> 300], Show[hist1, shist, ImageSize -> 300]]


        enter image description here



        We first find the scaling factor using the maximum heights in hist1 and hist2:



        scale = Divide @@ (Max[Cases[#[[1]], Rectangle[_, _, _, h_, ___] :> h, ∞]] & /@ 
        hist2, hist1);


        Since the scaling of the vertical axis is linear, we can simply re-scale the tick labels using Charting`FindTicks:



        Row[Show[hist2, ImageSize -> 300], 
        Show[hist1, shist, Ticks -> Automatic, Charting`FindTicks[0, 1/scale, 0, 1],
        PlotLabel -> "Probability", ImageSize -> 300]]


        enter image description here



         







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        kglr

        164k8188388




        164k8188388



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183326%2fsmoothhistogram-as-probability%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery