How to plot a Histogram and compare with a particular probability density function PDFMathematica envelope...
Justifying the use of directed energy weapons
The teacher logged me in as administrator for doing a short task, is the whole system now compromised?
Is “I am getting married with my sister” ambiguous?
How to dismiss intrusive questions from a colleague with whom I don't work?
What to say to a student who has failed?
Church Booleans
Potential new partner angry about first collaboration - how to answer email to close up this encounter in a graceful manner
Why doesn't the Falcon-9 first stage use three legs to land?
IndexOptimize - Configuration
Why don't electrons take the shorter path in coils
What does it mean to have a subnet mask /32?
Why didn’t Doctor Strange stay in the original winning timeline?
If all stars rotate, why was there a theory developed, that requires non-rotating stars?
Do AT motherboards (286, 386, 486) really need -5V (besides redirecting it to ISA connectors)?
What is wrong about this application of Kirchhoffs Current Law?
Concatenation of the result of a function with a mutable default argument in python
Verb form to finish someone else's sentence?
Why were movies shot on film shot at 24 frames per second?
How is "sein" conjugated in this sub-sentence?
Why is Boris Johnson visiting only Paris & Berlin if every member of the EU needs to agree on a withdrawal deal?
Which household object drew this pattern?
Why does my house heat up, even when it's cool outside?
What professions would a medieval village with a population of 100 need?
Is it possible to create a golf ball sized star?
How to plot a Histogram and compare with a particular probability density function PDF
Mathematica envelope for the bottom of a plot, a generic functionHow can I show a rotated PDF plot superimposed on a ListPlot of the underlying data?Rasterized density plot with vector axesProbabilityDistribution only accepts dx=1 for discrete distributionsHistogram: Compare PDF to DataObtain Plot for Continuous Probability Density Function Approximation from Discrete DataGetting PDF from imported HistogramSmooth Density Histogram with probability areasHow to plot weighted sum of functions?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
I would like to know how to plot a make a comparison between a histogram and a set of random data, I have the following probability density function (PDF) which is given for this problem. I can generate the histogram but I do not know how to add the PDF function and make the plot both together.
I have seen some question and problem using RandomVariate function but it does not work. This is the code.
Clear["Global`*"]; Remove["Global`*"];
L = 10; Ns = 10^4;
x = Table[RandomReal[L], {x, 0,Ns}];
y = Table[RandomReal[L], {y, 0, Ns}];
z = Table[RandomReal[L], {z, 0, Ns}];
sf = Abs[Sin[x^2 + y^2] + Cos[x y z]];
Histogram[sf, {0.25}, "Probability"]
The (PDF) is f = k^2/(k^2 + 1)^(5/2)
The goal is to obtain a similar plot like this, , where the line represent in this case f.
plotting graphics probability-or-statistics pdf-format
$endgroup$
add a comment |
$begingroup$
I would like to know how to plot a make a comparison between a histogram and a set of random data, I have the following probability density function (PDF) which is given for this problem. I can generate the histogram but I do not know how to add the PDF function and make the plot both together.
I have seen some question and problem using RandomVariate function but it does not work. This is the code.
Clear["Global`*"]; Remove["Global`*"];
L = 10; Ns = 10^4;
x = Table[RandomReal[L], {x, 0,Ns}];
y = Table[RandomReal[L], {y, 0, Ns}];
z = Table[RandomReal[L], {z, 0, Ns}];
sf = Abs[Sin[x^2 + y^2] + Cos[x y z]];
Histogram[sf, {0.25}, "Probability"]
The (PDF) is f = k^2/(k^2 + 1)^(5/2)
The goal is to obtain a similar plot like this, , where the line represent in this case f.
plotting graphics probability-or-statistics pdf-format
$endgroup$
$begingroup$
There are a number of problems with your formulation. First, you do not needx = Table[RandomReal[L], {x, 0,Ns}];
the x on the RHS is superfluous, and likely to cause problems. All you need is:x = RandomReal[10, 10^4];
Second, your random data sf is constrained to lie between 0 and 2 (i.e. is bounded). Your pdf is not bounded (or if it is, it is not stated). Third, even if your density was unbounded, it does not integrate to unity, so is not well-defined. All that leaves aside the fact that the density does not fit the data.
$endgroup$
– wolfies
2 days ago
add a comment |
$begingroup$
I would like to know how to plot a make a comparison between a histogram and a set of random data, I have the following probability density function (PDF) which is given for this problem. I can generate the histogram but I do not know how to add the PDF function and make the plot both together.
I have seen some question and problem using RandomVariate function but it does not work. This is the code.
Clear["Global`*"]; Remove["Global`*"];
L = 10; Ns = 10^4;
x = Table[RandomReal[L], {x, 0,Ns}];
y = Table[RandomReal[L], {y, 0, Ns}];
z = Table[RandomReal[L], {z, 0, Ns}];
sf = Abs[Sin[x^2 + y^2] + Cos[x y z]];
Histogram[sf, {0.25}, "Probability"]
The (PDF) is f = k^2/(k^2 + 1)^(5/2)
The goal is to obtain a similar plot like this, , where the line represent in this case f.
plotting graphics probability-or-statistics pdf-format
$endgroup$
I would like to know how to plot a make a comparison between a histogram and a set of random data, I have the following probability density function (PDF) which is given for this problem. I can generate the histogram but I do not know how to add the PDF function and make the plot both together.
I have seen some question and problem using RandomVariate function but it does not work. This is the code.
Clear["Global`*"]; Remove["Global`*"];
L = 10; Ns = 10^4;
x = Table[RandomReal[L], {x, 0,Ns}];
y = Table[RandomReal[L], {y, 0, Ns}];
z = Table[RandomReal[L], {z, 0, Ns}];
sf = Abs[Sin[x^2 + y^2] + Cos[x y z]];
Histogram[sf, {0.25}, "Probability"]
The (PDF) is f = k^2/(k^2 + 1)^(5/2)
The goal is to obtain a similar plot like this, , where the line represent in this case f.
plotting graphics probability-or-statistics pdf-format
plotting graphics probability-or-statistics pdf-format
asked 2 days ago
irondonioirondonio
1257 bronze badges
1257 bronze badges
$begingroup$
There are a number of problems with your formulation. First, you do not needx = Table[RandomReal[L], {x, 0,Ns}];
the x on the RHS is superfluous, and likely to cause problems. All you need is:x = RandomReal[10, 10^4];
Second, your random data sf is constrained to lie between 0 and 2 (i.e. is bounded). Your pdf is not bounded (or if it is, it is not stated). Third, even if your density was unbounded, it does not integrate to unity, so is not well-defined. All that leaves aside the fact that the density does not fit the data.
$endgroup$
– wolfies
2 days ago
add a comment |
$begingroup$
There are a number of problems with your formulation. First, you do not needx = Table[RandomReal[L], {x, 0,Ns}];
the x on the RHS is superfluous, and likely to cause problems. All you need is:x = RandomReal[10, 10^4];
Second, your random data sf is constrained to lie between 0 and 2 (i.e. is bounded). Your pdf is not bounded (or if it is, it is not stated). Third, even if your density was unbounded, it does not integrate to unity, so is not well-defined. All that leaves aside the fact that the density does not fit the data.
$endgroup$
– wolfies
2 days ago
$begingroup$
There are a number of problems with your formulation. First, you do not need
x = Table[RandomReal[L], {x, 0,Ns}];
the x on the RHS is superfluous, and likely to cause problems. All you need is: x = RandomReal[10, 10^4];
Second, your random data sf is constrained to lie between 0 and 2 (i.e. is bounded). Your pdf is not bounded (or if it is, it is not stated). Third, even if your density was unbounded, it does not integrate to unity, so is not well-defined. All that leaves aside the fact that the density does not fit the data.$endgroup$
– wolfies
2 days ago
$begingroup$
There are a number of problems with your formulation. First, you do not need
x = Table[RandomReal[L], {x, 0,Ns}];
the x on the RHS is superfluous, and likely to cause problems. All you need is: x = RandomReal[10, 10^4];
Second, your random data sf is constrained to lie between 0 and 2 (i.e. is bounded). Your pdf is not bounded (or if it is, it is not stated). Third, even if your density was unbounded, it does not integrate to unity, so is not well-defined. All that leaves aside the fact that the density does not fit the data.$endgroup$
– wolfies
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Use Show
:
Show[
Histogram[sf, {0.25}, "Probability"],
Plot[f, {k, 0, 2}]
]
$endgroup$
$begingroup$
I think you want"PDF"
rather than"Probability"
.
$endgroup$
– JimB
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
add a comment |
Your Answer
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',
autoActivateHeartbeat: false,
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
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f203940%2fhow-to-plot-a-histogram-and-compare-with-a-particular-probability-density-functi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Use Show
:
Show[
Histogram[sf, {0.25}, "Probability"],
Plot[f, {k, 0, 2}]
]
$endgroup$
$begingroup$
I think you want"PDF"
rather than"Probability"
.
$endgroup$
– JimB
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
add a comment |
$begingroup$
Use Show
:
Show[
Histogram[sf, {0.25}, "Probability"],
Plot[f, {k, 0, 2}]
]
$endgroup$
$begingroup$
I think you want"PDF"
rather than"Probability"
.
$endgroup$
– JimB
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
add a comment |
$begingroup$
Use Show
:
Show[
Histogram[sf, {0.25}, "Probability"],
Plot[f, {k, 0, 2}]
]
$endgroup$
Use Show
:
Show[
Histogram[sf, {0.25}, "Probability"],
Plot[f, {k, 0, 2}]
]
answered 2 days ago
ThemisThemis
5313 silver badges10 bronze badges
5313 silver badges10 bronze badges
$begingroup$
I think you want"PDF"
rather than"Probability"
.
$endgroup$
– JimB
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
add a comment |
$begingroup$
I think you want"PDF"
rather than"Probability"
.
$endgroup$
– JimB
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
$begingroup$
I think you want
"PDF"
rather than "Probability"
.$endgroup$
– JimB
2 days ago
$begingroup$
I think you want
"PDF"
rather than "Probability"
.$endgroup$
– JimB
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
$begingroup$
You're right, I coppied/pasted the code from the OP.
$endgroup$
– Themis
2 days ago
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f203940%2fhow-to-plot-a-histogram-and-compare-with-a-particular-probability-density-functi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
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
$begingroup$
There are a number of problems with your formulation. First, you do not need
x = Table[RandomReal[L], {x, 0,Ns}];
the x on the RHS is superfluous, and likely to cause problems. All you need is:x = RandomReal[10, 10^4];
Second, your random data sf is constrained to lie between 0 and 2 (i.e. is bounded). Your pdf is not bounded (or if it is, it is not stated). Third, even if your density was unbounded, it does not integrate to unity, so is not well-defined. All that leaves aside the fact that the density does not fit the data.$endgroup$
– wolfies
2 days ago