Monte Carlo errors estimation routine The Next CEO of Stack OverflowSmall Markov chain Monte...
How can I open an app using Terminal?
How to write papers efficiently when English isn't my first language?
How should I support this large drywall patch?
Why do remote companies require working in the US?
In place solution to remove duplicates from a sorted list
Why use "finir par" instead of "finir de" before an infinitive?
Return of the Riley Riddles in Reverse
How do spells that require an ability check vs spell save DC work?
How do I go from 300 unfinished/half written blog posts, to published posts?
Only print output after finding pattern
How to safely derail a train during transit?
The King's new dress
Crossing the line between justified force and brutality
How to make a software documentation "officially" citable?
What is the difference in properties java.runtime.version and java.version
Is HostGator storing my password in plaintext?
How to draw fully connected graph link picture bellow in latex?
Fastest way to shutdown Ubuntu Mate 18.10
Why did we only see the N-1 starfighters in one film?
Apart from "berlinern", do any other German dialects have a corresponding verb?
How do scammers retract money, while you can’t?
Why is Miller's case titled R (Miller)?
How to make a variable always equal to the result of some calculations?
What is the purpose of the Potent Cantrip ability?
Monte Carlo errors estimation routine
The Next CEO of Stack OverflowSmall Markov chain Monte Carlo implementationMonte Carlo coin flip simulationMonte Carlo estimation of the Hypergeometric FunctionHamiltonian Monte Carlo in ScalaMonte Carlo AI in 21 gameMonte Carlo pi calculationMonte Carlo asset price simulationMonte Carlo simulation of amoeba populationMonte Carlo simulation to price an Option in PythonMonte Carlo Simulation of P-Value
$begingroup$
I would value your opinion on the following piece of code. I am rather new to both Python and Monte Carlo analysis, so I was wondering whether the routine makes sense to more experienced and knowledgeable users.
def MC_analysis_a():
x = spin_lock_durations
y_signal_a = (a_norm1, a_norm2, a_norm3, a_norm4, a_norm5, a_norm6, a_norm7, a_norm8)
x = np.array(x, dtype = float)
y_signal_a = np.array(y_signal_a, dtype = float)
def func(x, a, b):
return a * np.exp(-b * x)
initial_guess = [1.0, 1.0]
fitting_parameters, covariance_matrix = optimize.curve_fit(func, x, y_signal_a, initial_guess)
print(round(fitting_parameters[1], 2))
# ---> PRODUCING PARAMETERS ESTIMATES
total_iterations = 5000
MC_pars = np.array([])
for iTrial in range(total_iterations):
xTrial = x
yTrial = y_signal_a + np.random.normal(loc = y_signal_a, scale = e_signal_a, size = np.size(y_signal_a))
try:
iteration_identifiers, covariance_matrix = optimize.curve_fit(func, xTrial, yTrial, initial_guess)
except:
dumdum = 1
continue
# ---> STACKING RESULTS
if np.size(MC_pars) < 1:
MC_pars = np.copy(iteration_identifiers)
else:
MC_pars = np.vstack((MC_pars, iteration_identifiers))
# ---> SLICING THE ARRAY
print(np.shape(MC_pars))
# print(np.median(aFitpyars[:,1]))
print(np.std(MC_pars[:,1]))
The output I get is apparently satisfactory and plausible.
Many thanks in advance to any contributor!
python numpy statistics
New contributor
$endgroup$
add a comment |
$begingroup$
I would value your opinion on the following piece of code. I am rather new to both Python and Monte Carlo analysis, so I was wondering whether the routine makes sense to more experienced and knowledgeable users.
def MC_analysis_a():
x = spin_lock_durations
y_signal_a = (a_norm1, a_norm2, a_norm3, a_norm4, a_norm5, a_norm6, a_norm7, a_norm8)
x = np.array(x, dtype = float)
y_signal_a = np.array(y_signal_a, dtype = float)
def func(x, a, b):
return a * np.exp(-b * x)
initial_guess = [1.0, 1.0]
fitting_parameters, covariance_matrix = optimize.curve_fit(func, x, y_signal_a, initial_guess)
print(round(fitting_parameters[1], 2))
# ---> PRODUCING PARAMETERS ESTIMATES
total_iterations = 5000
MC_pars = np.array([])
for iTrial in range(total_iterations):
xTrial = x
yTrial = y_signal_a + np.random.normal(loc = y_signal_a, scale = e_signal_a, size = np.size(y_signal_a))
try:
iteration_identifiers, covariance_matrix = optimize.curve_fit(func, xTrial, yTrial, initial_guess)
except:
dumdum = 1
continue
# ---> STACKING RESULTS
if np.size(MC_pars) < 1:
MC_pars = np.copy(iteration_identifiers)
else:
MC_pars = np.vstack((MC_pars, iteration_identifiers))
# ---> SLICING THE ARRAY
print(np.shape(MC_pars))
# print(np.median(aFitpyars[:,1]))
print(np.std(MC_pars[:,1]))
The output I get is apparently satisfactory and plausible.
Many thanks in advance to any contributor!
python numpy statistics
New contributor
$endgroup$
$begingroup$
Welcome to Code Review! In order to get the best possible outcome from the review please change your code so that is is runnable and complete (How to create a MWE?, minimal is not so important here). This allows users to verify that it is actually on-topic as well as to get a better feeling on what you actually want to accomplish.
$endgroup$
– Alex
47 mins ago
$begingroup$
Does the code need to be generalised in any particular way? Are you wanting to apply it to different datasets, or to fit a different family of curves? Do you want to store the output for further analysis?
$endgroup$
– Russ Hyde
46 mins ago
add a comment |
$begingroup$
I would value your opinion on the following piece of code. I am rather new to both Python and Monte Carlo analysis, so I was wondering whether the routine makes sense to more experienced and knowledgeable users.
def MC_analysis_a():
x = spin_lock_durations
y_signal_a = (a_norm1, a_norm2, a_norm3, a_norm4, a_norm5, a_norm6, a_norm7, a_norm8)
x = np.array(x, dtype = float)
y_signal_a = np.array(y_signal_a, dtype = float)
def func(x, a, b):
return a * np.exp(-b * x)
initial_guess = [1.0, 1.0]
fitting_parameters, covariance_matrix = optimize.curve_fit(func, x, y_signal_a, initial_guess)
print(round(fitting_parameters[1], 2))
# ---> PRODUCING PARAMETERS ESTIMATES
total_iterations = 5000
MC_pars = np.array([])
for iTrial in range(total_iterations):
xTrial = x
yTrial = y_signal_a + np.random.normal(loc = y_signal_a, scale = e_signal_a, size = np.size(y_signal_a))
try:
iteration_identifiers, covariance_matrix = optimize.curve_fit(func, xTrial, yTrial, initial_guess)
except:
dumdum = 1
continue
# ---> STACKING RESULTS
if np.size(MC_pars) < 1:
MC_pars = np.copy(iteration_identifiers)
else:
MC_pars = np.vstack((MC_pars, iteration_identifiers))
# ---> SLICING THE ARRAY
print(np.shape(MC_pars))
# print(np.median(aFitpyars[:,1]))
print(np.std(MC_pars[:,1]))
The output I get is apparently satisfactory and plausible.
Many thanks in advance to any contributor!
python numpy statistics
New contributor
$endgroup$
I would value your opinion on the following piece of code. I am rather new to both Python and Monte Carlo analysis, so I was wondering whether the routine makes sense to more experienced and knowledgeable users.
def MC_analysis_a():
x = spin_lock_durations
y_signal_a = (a_norm1, a_norm2, a_norm3, a_norm4, a_norm5, a_norm6, a_norm7, a_norm8)
x = np.array(x, dtype = float)
y_signal_a = np.array(y_signal_a, dtype = float)
def func(x, a, b):
return a * np.exp(-b * x)
initial_guess = [1.0, 1.0]
fitting_parameters, covariance_matrix = optimize.curve_fit(func, x, y_signal_a, initial_guess)
print(round(fitting_parameters[1], 2))
# ---> PRODUCING PARAMETERS ESTIMATES
total_iterations = 5000
MC_pars = np.array([])
for iTrial in range(total_iterations):
xTrial = x
yTrial = y_signal_a + np.random.normal(loc = y_signal_a, scale = e_signal_a, size = np.size(y_signal_a))
try:
iteration_identifiers, covariance_matrix = optimize.curve_fit(func, xTrial, yTrial, initial_guess)
except:
dumdum = 1
continue
# ---> STACKING RESULTS
if np.size(MC_pars) < 1:
MC_pars = np.copy(iteration_identifiers)
else:
MC_pars = np.vstack((MC_pars, iteration_identifiers))
# ---> SLICING THE ARRAY
print(np.shape(MC_pars))
# print(np.median(aFitpyars[:,1]))
print(np.std(MC_pars[:,1]))
The output I get is apparently satisfactory and plausible.
Many thanks in advance to any contributor!
python numpy statistics
python numpy statistics
New contributor
New contributor
New contributor
asked 1 hour ago
Shawn Marion fanShawn Marion fan
61
61
New contributor
New contributor
$begingroup$
Welcome to Code Review! In order to get the best possible outcome from the review please change your code so that is is runnable and complete (How to create a MWE?, minimal is not so important here). This allows users to verify that it is actually on-topic as well as to get a better feeling on what you actually want to accomplish.
$endgroup$
– Alex
47 mins ago
$begingroup$
Does the code need to be generalised in any particular way? Are you wanting to apply it to different datasets, or to fit a different family of curves? Do you want to store the output for further analysis?
$endgroup$
– Russ Hyde
46 mins ago
add a comment |
$begingroup$
Welcome to Code Review! In order to get the best possible outcome from the review please change your code so that is is runnable and complete (How to create a MWE?, minimal is not so important here). This allows users to verify that it is actually on-topic as well as to get a better feeling on what you actually want to accomplish.
$endgroup$
– Alex
47 mins ago
$begingroup$
Does the code need to be generalised in any particular way? Are you wanting to apply it to different datasets, or to fit a different family of curves? Do you want to store the output for further analysis?
$endgroup$
– Russ Hyde
46 mins ago
$begingroup$
Welcome to Code Review! In order to get the best possible outcome from the review please change your code so that is is runnable and complete (How to create a MWE?, minimal is not so important here). This allows users to verify that it is actually on-topic as well as to get a better feeling on what you actually want to accomplish.
$endgroup$
– Alex
47 mins ago
$begingroup$
Welcome to Code Review! In order to get the best possible outcome from the review please change your code so that is is runnable and complete (How to create a MWE?, minimal is not so important here). This allows users to verify that it is actually on-topic as well as to get a better feeling on what you actually want to accomplish.
$endgroup$
– Alex
47 mins ago
$begingroup$
Does the code need to be generalised in any particular way? Are you wanting to apply it to different datasets, or to fit a different family of curves? Do you want to store the output for further analysis?
$endgroup$
– Russ Hyde
46 mins ago
$begingroup$
Does the code need to be generalised in any particular way? Are you wanting to apply it to different datasets, or to fit a different family of curves? Do you want to store the output for further analysis?
$endgroup$
– Russ Hyde
46 mins ago
add a comment |
0
active
oldest
votes
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.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
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
});
}
});
Shawn Marion fan is a new contributor. Be nice, and check out our Code of Conduct.
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%2fcodereview.stackexchange.com%2fquestions%2f216433%2fmonte-carlo-errors-estimation-routine%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Shawn Marion fan is a new contributor. Be nice, and check out our Code of Conduct.
Shawn Marion fan is a new contributor. Be nice, and check out our Code of Conduct.
Shawn Marion fan is a new contributor. Be nice, and check out our Code of Conduct.
Shawn Marion fan is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review 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%2fcodereview.stackexchange.com%2fquestions%2f216433%2fmonte-carlo-errors-estimation-routine%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$
Welcome to Code Review! In order to get the best possible outcome from the review please change your code so that is is runnable and complete (How to create a MWE?, minimal is not so important here). This allows users to verify that it is actually on-topic as well as to get a better feeling on what you actually want to accomplish.
$endgroup$
– Alex
47 mins ago
$begingroup$
Does the code need to be generalised in any particular way? Are you wanting to apply it to different datasets, or to fit a different family of curves? Do you want to store the output for further analysis?
$endgroup$
– Russ Hyde
46 mins ago