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
import numpy as np | |
import matplotlib | |
from matplotlib.patches import Circle | |
from matplotlib.collections import PatchCollection | |
import matplotlib.pyplot as plt | |
from numpy import linalg as LA | |
def demoGerschgorin(A): | |
n = len(A) |
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
sed -r 's/\$\$([^$$]*)\$\$/\\[\1\\]/g' INPUTFILE | sed -r 's/\$([^$]*)\$/\\(\1\\)/g' |
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
def integrand(r, f, rmin, rmax, mu, sigma): | |
"""defines the part inside the integral sign""" | |
from scipy.stats import truncnorm | |
a, b = (rmin - mu)/sigma, (rmax - mu) /sigma | |
rv = truncnorm(a, b, loc=mu, scale=sigma) | |
return rv.pdf(r) * np.log(1 + f*(r-1)) | |
def logS(f, rmin, rmax, mu, sigma): | |
"""numerically solves the integral""" | |
from scipy.integrate import quad |
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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
#!/usr/bin/env python3 | |
# | |
# (c) Sachin Shanbhag, 2015 | |
# Last Modified: Jan 5, 2020 (input change to space separated; python3 compliance) | |
# | |
# Given a set of contributions (and optionally expemptions) creates a list of pair-wise | |
# transactions which "settles" all accounts | |
# | |
# example : python splitup.py INPUTFILENAME | |
# |
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
def logWeightedAverage(L, R): | |
n = len(L) | |
Lscale = 0. | |
sumNumerator = 0. | |
sumDenominator = 0. | |
for j in range(n): | |
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
! | |
! Program to demonstrate the use of Fortran 90's intrinsic random_number() | |
! | |
program main | |
integer :: values(8), k, nseed | |
integer, dimension(:), allocatable :: seed | |
real(8) :: r(10) |
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
n = 15; % number of collocation points is (n+1) | |
nmodes = 5; % number of modes of the DCS | |
xi = [0:n]'/(n+1); % collocation points for discrete cosine series | |
V = zeros(n+1, nmodes); | |
% | |
% V: stack the nmodes DCS basis functions columnwise | |
% | |
for j = 1:nmodes |
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
n = 15; % number of collocation points is (n+1) | |
nmodes = 5; % number of modes of the DCS | |
xi = [0:n]'/(n+1); % collocation points for DCS | |
V = zeros(n+1, nmodes); | |
% | |
% V: stack the nmodes DCS basis functions columnwise | |
% |
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
function s = KahanSum(x) | |
s = 0; % the sum | |
r = 0; % the error or remainder | |
for i = 1:length(x) | |
tmp = s; | |
y = x(i) + r; | |
s = tmp + y; % s = s + x_i | |
r = (tmp - s) + y; |