SmoothHistogram as âProbabilityâ?
Clash 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"
?
probability-or-statistics
add a comment |Â
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"
?
probability-or-statistics
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 usingSmoothHistogram
, you could compute aSmoothKernelDistribution
, thenPlot
thePDF
of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
â Szabolcs
4 hours ago
add a comment |Â
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"
?
probability-or-statistics
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
probability-or-statistics
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 usingSmoothHistogram
, you could compute aSmoothKernelDistribution
, thenPlot
thePDF
of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.
â Szabolcs
4 hours ago
add a comment |Â
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 usingSmoothHistogram
, you could compute aSmoothKernelDistribution
, thenPlot
thePDF
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
add a comment |Â
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]]
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]]
ÃÂ
add a comment |Â
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]]
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]]
ÃÂ
add a comment |Â
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]]
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]]
ÃÂ
add a comment |Â
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]]
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]]
ÃÂ
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]]
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]]
ÃÂ
answered 2 hours ago
kglr
164k8188388
164k8188388
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 aSmoothKernelDistribution
, thenPlot
thePDF
of its output with an appropriate scaling factor (i.e. the bin width) to match the binned histogram.â Szabolcs
4 hours ago