Created
March 26, 2014 07:56
-
-
Save keitheis/9778526 to your computer and use it in GitHub Desktop.
Test NumPy, SciPy, and Matplotlib installed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy from http://www.scipy.org/getting-started.html | |
import argparse | |
import numpy as np | |
from scipy import special, optimize | |
import matplotlib.pyplot as plt | |
def main(): | |
# Parse command-line arguments | |
parser = argparse.ArgumentParser(usage=__doc__) | |
parser.add_argument("--order", type=int, default=3, help="order of Bessel function") | |
parser.add_argument("--output", default="plot.png", help="output image file") | |
args = parser.parse_args() | |
# Compute maximum | |
f = lambda x: -special.jv(args.order, x) | |
sol = optimize.minimize(f, 1.0) | |
# Plot | |
x = np.linspace(0, 10, 5000) | |
plt.plot(x, special.jv(args.order, x), '-', sol.x, -sol.fun, 'o') | |
# Produce output | |
plt.savefig(args.output, dpi=96) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!