Skip to content

Conversation

@nkanazawa1989
Copy link
Collaborator

@nkanazawa1989 nkanazawa1989 commented Jul 27, 2021

Summary

This adds a fit model information to analysis result generated by a CurveAnalysis subclass.

Requested by @blakejohnson

Details and comments

The latex curve description is attached to SeriesDef, which is loaded by the CurveAnalysis and attached to the analysis result. User can directly find fit model without reading analysis class API docs. The fit_models field is a dictionary with a key of curve series name (defaults to 'Series-0').

>>>result = expdata.analysis_results(0)
>>>result.data()

{'analysis_type': 'RBAnalysis',
 'fit_models': {'Series-0': 'a \\alpha^x + b'},  # here you can see the fit model
 'popt': array([0.47952175, 0.99731565, 0.50743179]),
 'popt_keys': ['a', 'alpha', 'b'],
 'popt_err': array([0.01895722, 0.00026991, 0.01903137]),
 'pcov': array([[ 3.59376014e-04,  4.66670548e-06, -3.55879364e-04],
        [ 4.66670548e-06,  7.28526705e-08, -4.80580271e-06],
        [-3.55879364e-04, -4.80580271e-06,  3.62193134e-04]]),
 'reduced_chisq': 0.2795941802830343,
 'dof': 7,
 'xrange': [1.0, 901.0],
 'success': True,
 'EPC': 0.0013421750216636719,
 'EPC_err': 0.00013531941396415328,
 'EPG': {0: {'rz': 0.0,
   'sx': 0.00043402011888714933,
   'x': 0.00043402011888714933}}}

@nkanazawa1989 nkanazawa1989 added this to the Release 0.1 milestone Jul 27, 2021
@@ -1,158 +1,159 @@
# This code is part of Qiskit.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why GitHub is showing this entire file as changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is it's different newline characters (windows vs unix)

y = {\rm amp} \sin\left(2 \pi {\fm freq} x + {\rm phase}\right) + {\rm baseline}
"""
return amp * np.cos(2 * np.pi * freq * x + phase) + baseline
return amp * np.sin(2 * np.pi * freq * x + phase) + baseline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

Copy link
Contributor

@blakejohnson blakejohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a nice enhancement.

knzwnao added 7 commits August 20, 2021 03:00
…ade/math_model

# Conflicts:
#	qiskit_experiments/curve_analysis/curve_analysis.py
#	qiskit_experiments/curve_analysis/curve_data.py
#	qiskit_experiments/library/calibration/analysis/drag_analysis.py
#	qiskit_experiments/library/calibration/analysis/fine_amplitude_analysis.py
#	test/curve_analysis/test_curve_fit.py
#	test/randomized_benchmarking/test_rb_analysis.py
@nkanazawa1989 nkanazawa1989 merged commit c903205 into qiskit-community:main Aug 20, 2021
paco-ri pushed a commit to paco-ri/qiskit-experiments that referenced this pull request Jul 11, 2022
* add fit model metadata

* update curve fit test

* update ub test

* black

* fit model description defaults to None

* fix descriptions

* update rb test cache files

* add reno

* fix typo

* update reno
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants