From bc4525a817f9f89d046cd9aafd1e496d147e0744 Mon Sep 17 00:00:00 2001 From: Niyonika Gaur <83643952+niyonikagaur@users.noreply.github.com> Date: Thu, 16 May 2024 14:22:43 +0530 Subject: [PATCH 1/9] Create Intro_SciPy.md --- Intro_SciPy.md | 136 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Intro_SciPy.md diff --git a/Intro_SciPy.md b/Intro_SciPy.md new file mode 100644 index 0000000..afd8b3a --- /dev/null +++ b/Intro_SciPy.md @@ -0,0 +1,136 @@ +# Introduction to SciPy +#### Python has a powerful library known as SciPy that is used for scientific and technical computing. It functions by extending the capabilities of NumPy and providing numerous operations for numerical data. Although the same library, SciPy is divided into distinct sections meant for various scientific computations. +## Installation of Scipy +### Install using the command: +#### C:\Users\Your Name>pip install scipy + You can also use a Python distribution that already has Scipy installed like Anaconda or Spyder. +### Importing SciPy +#### from scipy import constants +## Key Features of SciPy +### 1. Numerical Integration +#### It helps in computing definite or indefinite integrals of functions +``` +from scipy import integrate + +#Define the function to integrate +def f(x): + return x**2 + +#Compute definite integral of f from 0 to 1 +result, error = integrate.quad(f, 0, 1) +print(result) +``` +#### Output +``` +0.33333333333333337 +``` +### 2. Optimization +#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation +``` +from scipy.optimize import minimize + +# Define an objective function to minimize +def objective(x): + return x**2 + 10*np.sin(x) + +# Minimize the objective function starting from x=0 +result = minimize(objective, x0=0) +print(result.x) +``` +#### Output +``` +array([-1.30644012]) +``` +### 3. Linear Algebra +#### Solving Linear computations +``` +from scipy import linalg +import numpy as np + +# Define a square matrix +A = np.array([[1, 2], [3, 4]]) + +# Define a vector +b = np.array([5, 6]) + +# Solve Ax = b for x +x = linalg.solve(A, b) +print(x) +``` +#### Output +``` +array([-4. , 4.5]) +``` +### 4. Statistics +#### Performing statistics functions, like here we'll be distributing the data +``` +from scipy import stats +import numpy as np + +# Generate random data from a normal distribution +data = stats.norm.rvs(loc=0, scale=1, size=1000) + +# Fit a normal distribution to the data +mean, std = stats.norm.fit(data) +``` +### 5. Signal Processing +#### To process spectral signals, like EEG or MEG +``` +from scipy import signal +import numpy as np + +# Create a signal (e.g., sine wave) +t = np.linspace(0, 1, 1000) +signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000) + +# Apply a low-pass Butterworth filter +b, a = signal.butter(4, 0.1, 'low') +filtered_signal = signal.filtfilt(b, a, signal) +``` +The various filters applied that are applied here, are a part of signal analysis at a deeper level. +### 6. Sparse Matrix +#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created +#### There are two types of Sparse Matrices: +##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing +##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing +#### In CSC format +``` +from scipy import sparse +import numpy as np + +data = np.array([[0, 0], [0, 1], [2, 0]]) + +row_indices = np.array([1, 2, 1]) +col_indices = np.array([1, 0, 2]) +values = np.array([1, 2, 1]) + +sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) +``` +#### In CSR format +``` +from scipy import sparse +import numpy as np + +data = np.array([[0, 0], [0, 1], [2, 0]]) +sparse_matrix = sparse.csr_matrix(data) +``` +### 7. Image Processing +#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. +``` +from scipy import ndimage +import matplotlib.pyplot as plt + +image = plt.imread('path/to/image.jpg') +plt.imshow(image) +plt.show() + +# Apply Gaussian blur to the image +blurred_image = ndimage.gaussian_filter(image, sigma=1) +plt.imshow(blurred_image) +plt.show() +``` +#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image. + + + + From 1834690a1064b0e280d1d8f4e6c31ca61f3f13b9 Mon Sep 17 00:00:00 2001 From: Niyonika Gaur <83643952+niyonikagaur@users.noreply.github.com> Date: Fri, 17 May 2024 23:37:59 +0530 Subject: [PATCH 2/9] Introduction_to_SciPy.md --- contrib/scipy/index.md | 132 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/contrib/scipy/index.md b/contrib/scipy/index.md index 82596a2..9c35f95 100644 --- a/contrib/scipy/index.md +++ b/contrib/scipy/index.md @@ -1,3 +1,131 @@ -# List of sections +## Installation of Scipy +### Install using the command: +#### C:\Users\Your Name>pip install scipy + You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder. +### Importing SciPy +#### from scipy import constants +## Key Features of SciPy +### 1. Numerical Integration +#### It helps in computing definite or indefinite integrals of functions +``` +from scipy import integrate + +#Define the function to integrate +def f(x): + return x**2 + +#Compute definite integral of f from 0 to 1 +result, error = integrate.quad(f, 0, 1) +print(result) +``` +#### Output +``` +0.33333333333333337 +``` +### 2. Optimization +#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation +``` +from scipy.optimize import minimize + +# Define an objective function to minimize +def objective(x): + return x**2 + 10*np.sin(x) + +# Minimize the objective function starting from x=0 +result = minimize(objective, x0=0) +print(result.x) +``` +#### Output +``` +array([-1.30644012]) +``` +### 3. Linear Algebra +#### Solving Linear computations +``` +from scipy import linalg +import numpy as np + +# Define a square matrix +A = np.array([[1, 2], [3, 4]]) + +# Define a vector +b = np.array([5, 6]) + +# Solve Ax = b for x +x = linalg.solve(A, b) +print(x) +``` +#### Output +``` +array([-4. , 4.5]) +``` +### 4. Statistics +#### Performing statistics functions, like here we'll be distributing the data +``` +from scipy import stats +import numpy as np + +# Generate random data from a normal distribution +data = stats.norm.rvs(loc=0, scale=1, size=1000) + +# Fit a normal distribution to the data +mean, std = stats.norm.fit(data) +``` +### 5. Signal Processing +#### To process spectral signals, like EEG or MEG +``` +from scipy import signal +import numpy as np + +# Create a signal (e.g., sine wave) +t = np.linspace(0, 1, 1000) +signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000) + +# Apply a low-pass Butterworth filter +b, a = signal.butter(4, 0.1, 'low') +filtered_signal = signal.filtfilt(b, a, signal) +``` +The various filters applied that are applied here, are a part of signal analysis at a deeper level. +### 6. Sparse Matrix +#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created +#### There are two types of Sparse Matrices: +##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing +##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing +#### In CSC format +``` +from scipy import sparse +import numpy as np + +data = np.array([[0, 0], [0, 1], [2, 0]]) + +row_indices = np.array([1, 2, 1]) +col_indices = np.array([1, 0, 2]) +values = np.array([1, 2, 1]) + +sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) +``` +#### In CSR format +``` +from scipy import sparse +import numpy as np + +data = np.array([[0, 0], [0, 1], [2, 0]]) +sparse_matrix = sparse.csr_matrix(data) +``` +### 7. Image Processing +#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. +``` +from scipy import ndimage +import matplotlib.pyplot as plt + +image = plt.imread('path/to/image.jpg') +plt.imshow(image) +plt.show() + +# Apply Gaussian blur to the image +blurred_image = ndimage.gaussian_filter(image, sigma=1) +plt.imshow(blurred_image) +plt.show() +``` +#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image. -- [Section title](filename.md) From 7c3b30466982483e69db3513e0afc438e982cad8 Mon Sep 17 00:00:00 2001 From: Niyonika Gaur <83643952+niyonikagaur@users.noreply.github.com> Date: Fri, 17 May 2024 23:58:14 +0530 Subject: [PATCH 3/9] Update index.md --- contrib/scipy/index.md | 131 +---------------------------------------- 1 file changed, 2 insertions(+), 129 deletions(-) diff --git a/contrib/scipy/index.md b/contrib/scipy/index.md index 9c35f95..3ff5a7d 100644 --- a/contrib/scipy/index.md +++ b/contrib/scipy/index.md @@ -1,131 +1,4 @@ -## Installation of Scipy -### Install using the command: -#### C:\Users\Your Name>pip install scipy - You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder. -### Importing SciPy -#### from scipy import constants -## Key Features of SciPy -### 1. Numerical Integration -#### It helps in computing definite or indefinite integrals of functions -``` -from scipy import integrate +# List of sections -#Define the function to integrate -def f(x): - return x**2 - -#Compute definite integral of f from 0 to 1 -result, error = integrate.quad(f, 0, 1) -print(result) -``` -#### Output -``` -0.33333333333333337 -``` -### 2. Optimization -#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation -``` -from scipy.optimize import minimize - -# Define an objective function to minimize -def objective(x): - return x**2 + 10*np.sin(x) - -# Minimize the objective function starting from x=0 -result = minimize(objective, x0=0) -print(result.x) -``` -#### Output -``` -array([-1.30644012]) -``` -### 3. Linear Algebra -#### Solving Linear computations -``` -from scipy import linalg -import numpy as np - -# Define a square matrix -A = np.array([[1, 2], [3, 4]]) - -# Define a vector -b = np.array([5, 6]) - -# Solve Ax = b for x -x = linalg.solve(A, b) -print(x) -``` -#### Output -``` -array([-4. , 4.5]) -``` -### 4. Statistics -#### Performing statistics functions, like here we'll be distributing the data -``` -from scipy import stats -import numpy as np - -# Generate random data from a normal distribution -data = stats.norm.rvs(loc=0, scale=1, size=1000) - -# Fit a normal distribution to the data -mean, std = stats.norm.fit(data) -``` -### 5. Signal Processing -#### To process spectral signals, like EEG or MEG -``` -from scipy import signal -import numpy as np - -# Create a signal (e.g., sine wave) -t = np.linspace(0, 1, 1000) -signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000) - -# Apply a low-pass Butterworth filter -b, a = signal.butter(4, 0.1, 'low') -filtered_signal = signal.filtfilt(b, a, signal) -``` -The various filters applied that are applied here, are a part of signal analysis at a deeper level. -### 6. Sparse Matrix -#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created -#### There are two types of Sparse Matrices: -##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing -##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing -#### In CSC format -``` -from scipy import sparse -import numpy as np - -data = np.array([[0, 0], [0, 1], [2, 0]]) - -row_indices = np.array([1, 2, 1]) -col_indices = np.array([1, 0, 2]) -values = np.array([1, 2, 1]) - -sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) -``` -#### In CSR format -``` -from scipy import sparse -import numpy as np - -data = np.array([[0, 0], [0, 1], [2, 0]]) -sparse_matrix = sparse.csr_matrix(data) -``` -### 7. Image Processing -#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. -``` -from scipy import ndimage -import matplotlib.pyplot as plt - -image = plt.imread('path/to/image.jpg') -plt.imshow(image) -plt.show() - -# Apply Gaussian blur to the image -blurred_image = ndimage.gaussian_filter(image, sigma=1) -plt.imshow(blurred_image) -plt.show() -``` -#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image. +- [Installation of Scipy and its key uses](pandas_series_vs_numpy_ndarray.md) From 0a63d2e17d69b8d8d3032bf36c51a183dc0e2450 Mon Sep 17 00:00:00 2001 From: Niyonika Gaur <83643952+niyonikagaur@users.noreply.github.com> Date: Fri, 17 May 2024 23:59:25 +0530 Subject: [PATCH 4/9] Installation_of_Scipy_&_its_key_uses.md --- .../Installation_of_Scipy_&_its_key_uses.md | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 contrib/scipy/Installation_of_Scipy_&_its_key_uses.md diff --git a/contrib/scipy/Installation_of_Scipy_&_its_key_uses.md b/contrib/scipy/Installation_of_Scipy_&_its_key_uses.md new file mode 100644 index 0000000..33232dc --- /dev/null +++ b/contrib/scipy/Installation_of_Scipy_&_its_key_uses.md @@ -0,0 +1,130 @@ +## Installation of Scipy +### Install using the command: +#### C:\Users\Your Name>pip install scipy + You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder. +### Importing SciPy +#### from scipy import constants +## Key Features of SciPy +### 1. Numerical Integration +#### It helps in computing definite or indefinite integrals of functions +``` +from scipy import integrate + +#Define the function to integrate +def f(x): + return x**2 + +#Compute definite integral of f from 0 to 1 +result, error = integrate.quad(f, 0, 1) +print(result) +``` +#### Output +``` +0.33333333333333337 +``` +### 2. Optimization +#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation +``` +from scipy.optimize import minimize + +# Define an objective function to minimize +def objective(x): + return x**2 + 10*np.sin(x) + +# Minimize the objective function starting from x=0 +result = minimize(objective, x0=0) +print(result.x) +``` +#### Output +``` +array([-1.30644012]) +``` +### 3. Linear Algebra +#### Solving Linear computations +``` +from scipy import linalg +import numpy as np + +# Define a square matrix +A = np.array([[1, 2], [3, 4]]) + +# Define a vector +b = np.array([5, 6]) + +# Solve Ax = b for x +x = linalg.solve(A, b) +print(x) +``` +#### Output +``` +array([-4. , 4.5]) +``` +### 4. Statistics +#### Performing statistics functions, like here we'll be distributing the data +``` +from scipy import stats +import numpy as np + +# Generate random data from a normal distribution +data = stats.norm.rvs(loc=0, scale=1, size=1000) + +# Fit a normal distribution to the data +mean, std = stats.norm.fit(data) +``` +### 5. Signal Processing +#### To process spectral signals, like EEG or MEG +``` +from scipy import signal +import numpy as np + +# Create a signal (e.g., sine wave) +t = np.linspace(0, 1, 1000) +signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000) + +# Apply a low-pass Butterworth filter +b, a = signal.butter(4, 0.1, 'low') +filtered_signal = signal.filtfilt(b, a, signal) +``` +The various filters applied that are applied here, are a part of signal analysis at a deeper level. +### 6. Sparse Matrix +#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created +#### There are two types of Sparse Matrices: +##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing +##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing +#### In CSC format +``` +from scipy import sparse +import numpy as np + +data = np.array([[0, 0], [0, 1], [2, 0]]) + +row_indices = np.array([1, 2, 1]) +col_indices = np.array([1, 0, 2]) +values = np.array([1, 2, 1]) + +sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) +``` +#### In CSR format +``` +from scipy import sparse +import numpy as np + +data = np.array([[0, 0], [0, 1], [2, 0]]) +sparse_matrix = sparse.csr_matrix(data) +``` +### 7. Image Processing +#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. +``` +from scipy import ndimage +import matplotlib.pyplot as plt + +image = plt.imread('path/to/image.jpg') +plt.imshow(image) +plt.show() + +# Apply Gaussian blur to the image +blurred_image = ndimage.gaussian_filter(image, sigma=1) +plt.imshow(blurred_image) +plt.show() +``` +#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image. From 2632f7c8a1a542b98616668311e24d344ca79736 Mon Sep 17 00:00:00 2001 From: Niyonika Gaur <83643952+niyonikagaur@users.noreply.github.com> Date: Fri, 17 May 2024 23:59:48 +0530 Subject: [PATCH 5/9] Update index.md --- contrib/scipy/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scipy/index.md b/contrib/scipy/index.md index 3ff5a7d..abc2fb0 100644 --- a/contrib/scipy/index.md +++ b/contrib/scipy/index.md @@ -1,4 +1,4 @@ # List of sections -- [Installation of Scipy and its key uses](pandas_series_vs_numpy_ndarray.md) +- [Installation of Scipy and its key uses]( Installation_of_Scipy_&_its_key_uses.md) From b39147fb12bb40ce2652dc03737d60e3ab3ce23d Mon Sep 17 00:00:00 2001 From: Niyonika Gaur <83643952+niyonikagaur@users.noreply.github.com> Date: Thu, 23 May 2024 09:38:49 +0530 Subject: [PATCH 6/9] Delete Intro_SciPy.md --- Intro_SciPy.md | 136 ------------------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 Intro_SciPy.md diff --git a/Intro_SciPy.md b/Intro_SciPy.md deleted file mode 100644 index afd8b3a..0000000 --- a/Intro_SciPy.md +++ /dev/null @@ -1,136 +0,0 @@ -# Introduction to SciPy -#### Python has a powerful library known as SciPy that is used for scientific and technical computing. It functions by extending the capabilities of NumPy and providing numerous operations for numerical data. Although the same library, SciPy is divided into distinct sections meant for various scientific computations. -## Installation of Scipy -### Install using the command: -#### C:\Users\Your Name>pip install scipy - You can also use a Python distribution that already has Scipy installed like Anaconda or Spyder. -### Importing SciPy -#### from scipy import constants -## Key Features of SciPy -### 1. Numerical Integration -#### It helps in computing definite or indefinite integrals of functions -``` -from scipy import integrate - -#Define the function to integrate -def f(x): - return x**2 - -#Compute definite integral of f from 0 to 1 -result, error = integrate.quad(f, 0, 1) -print(result) -``` -#### Output -``` -0.33333333333333337 -``` -### 2. Optimization -#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation -``` -from scipy.optimize import minimize - -# Define an objective function to minimize -def objective(x): - return x**2 + 10*np.sin(x) - -# Minimize the objective function starting from x=0 -result = minimize(objective, x0=0) -print(result.x) -``` -#### Output -``` -array([-1.30644012]) -``` -### 3. Linear Algebra -#### Solving Linear computations -``` -from scipy import linalg -import numpy as np - -# Define a square matrix -A = np.array([[1, 2], [3, 4]]) - -# Define a vector -b = np.array([5, 6]) - -# Solve Ax = b for x -x = linalg.solve(A, b) -print(x) -``` -#### Output -``` -array([-4. , 4.5]) -``` -### 4. Statistics -#### Performing statistics functions, like here we'll be distributing the data -``` -from scipy import stats -import numpy as np - -# Generate random data from a normal distribution -data = stats.norm.rvs(loc=0, scale=1, size=1000) - -# Fit a normal distribution to the data -mean, std = stats.norm.fit(data) -``` -### 5. Signal Processing -#### To process spectral signals, like EEG or MEG -``` -from scipy import signal -import numpy as np - -# Create a signal (e.g., sine wave) -t = np.linspace(0, 1, 1000) -signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000) - -# Apply a low-pass Butterworth filter -b, a = signal.butter(4, 0.1, 'low') -filtered_signal = signal.filtfilt(b, a, signal) -``` -The various filters applied that are applied here, are a part of signal analysis at a deeper level. -### 6. Sparse Matrix -#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created -#### There are two types of Sparse Matrices: -##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing -##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing -#### In CSC format -``` -from scipy import sparse -import numpy as np - -data = np.array([[0, 0], [0, 1], [2, 0]]) - -row_indices = np.array([1, 2, 1]) -col_indices = np.array([1, 0, 2]) -values = np.array([1, 2, 1]) - -sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) -``` -#### In CSR format -``` -from scipy import sparse -import numpy as np - -data = np.array([[0, 0], [0, 1], [2, 0]]) -sparse_matrix = sparse.csr_matrix(data) -``` -### 7. Image Processing -#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. -``` -from scipy import ndimage -import matplotlib.pyplot as plt - -image = plt.imread('path/to/image.jpg') -plt.imshow(image) -plt.show() - -# Apply Gaussian blur to the image -blurred_image = ndimage.gaussian_filter(image, sigma=1) -plt.imshow(blurred_image) -plt.show() -``` -#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image. - - - - From 091a5daeda4ec4afb9d7c90ad249ad27fa0fdcf6 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Fri, 24 May 2024 21:07:23 +0530 Subject: [PATCH 7/9] Rename Installation_of_Scipy_&_its_key_uses.md to installation_features.md --- ...lation_of_Scipy_&_its_key_uses.md => installation_features.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/scipy/{Installation_of_Scipy_&_its_key_uses.md => installation_features.md} (100%) diff --git a/contrib/scipy/Installation_of_Scipy_&_its_key_uses.md b/contrib/scipy/installation_features.md similarity index 100% rename from contrib/scipy/Installation_of_Scipy_&_its_key_uses.md rename to contrib/scipy/installation_features.md From bcf4df6d7d13627d33a1419178db4f42dca12581 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Fri, 24 May 2024 21:08:03 +0530 Subject: [PATCH 8/9] Update index.md --- contrib/scipy/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scipy/index.md b/contrib/scipy/index.md index abc2fb0..5737114 100644 --- a/contrib/scipy/index.md +++ b/contrib/scipy/index.md @@ -1,4 +1,4 @@ # List of sections -- [Installation of Scipy and its key uses]( Installation_of_Scipy_&_its_key_uses.md) +- [Installation of Scipy and its key uses](installation_features.md) From e6a7ceee0cf230f7d8377f5f19b96a20ac1bfadd Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Fri, 24 May 2024 21:12:54 +0530 Subject: [PATCH 9/9] Update installation_features.md --- contrib/scipy/installation_features.md | 89 +++++++++++++++++++------- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/contrib/scipy/installation_features.md b/contrib/scipy/installation_features.md index 33232dc..d541086 100644 --- a/contrib/scipy/installation_features.md +++ b/contrib/scipy/installation_features.md @@ -1,13 +1,25 @@ ## Installation of Scipy -### Install using the command: -#### C:\Users\Your Name>pip install scipy - You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder. + +You can install scipy using the command: + +``` +$ pip install scipy +``` + +You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder. + ### Importing SciPy -#### from scipy import constants + +```python +from scipy import constants +``` + ## Key Features of SciPy ### 1. Numerical Integration -#### It helps in computing definite or indefinite integrals of functions -``` + +It helps in computing definite or indefinite integrals of functions + +```python from scipy import integrate #Define the function to integrate @@ -18,13 +30,18 @@ def f(x): result, error = integrate.quad(f, 0, 1) print(result) ``` + #### Output + ``` 0.33333333333333337 ``` + ### 2. Optimization -#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation -``` + +It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation + +```python from scipy.optimize import minimize # Define an objective function to minimize @@ -35,13 +52,18 @@ def objective(x): result = minimize(objective, x0=0) print(result.x) ``` + #### Output + ``` array([-1.30644012]) ``` + ### 3. Linear Algebra -#### Solving Linear computations -``` + +Solving Linear computations + +```python from scipy import linalg import numpy as np @@ -55,13 +77,18 @@ b = np.array([5, 6]) x = linalg.solve(A, b) print(x) ``` + #### Output + ``` array([-4. , 4.5]) ``` + ### 4. Statistics -#### Performing statistics functions, like here we'll be distributing the data -``` + +Performing statistics functions, like here we'll be distributing the data + +```python from scipy import stats import numpy as np @@ -71,9 +98,12 @@ data = stats.norm.rvs(loc=0, scale=1, size=1000) # Fit a normal distribution to the data mean, std = stats.norm.fit(data) ``` + ### 5. Signal Processing -#### To process spectral signals, like EEG or MEG -``` + +To process spectral signals, like EEG or MEG + +```python from scipy import signal import numpy as np @@ -85,14 +115,21 @@ signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000) b, a = signal.butter(4, 0.1, 'low') filtered_signal = signal.filtfilt(b, a, signal) ``` + The various filters applied that are applied here, are a part of signal analysis at a deeper level. + ### 6. Sparse Matrix -#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created -#### There are two types of Sparse Matrices: -##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing -##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing + +The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created + +There are two types of Sparse Matrices: + +1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing +2. CSR: Compressed Sparse Row, it is used for fast row slicing + #### In CSC format -``` + +```python from scipy import sparse import numpy as np @@ -104,17 +141,22 @@ values = np.array([1, 2, 1]) sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) ``` + #### In CSR format -``` + +```python from scipy import sparse import numpy as np data = np.array([[0, 0], [0, 1], [2, 0]]) sparse_matrix = sparse.csr_matrix(data) ``` + ### 7. Image Processing -#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. -``` + +It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used. + +```python from scipy import ndimage import matplotlib.pyplot as plt @@ -127,4 +169,5 @@ blurred_image = ndimage.gaussian_filter(image, sigma=1) plt.imshow(blurred_image) plt.show() ``` -#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image. + +The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image.