The input parameters for both functions are:
S
: the current stock priceK
: the strike price of the optionT
: the time to expiration of the option (in years)r
: the risk-free interest ratesigma
: the volatility of the stock price
Example usage:
from netaddr import IPNetwork | |
from ipaddress import IPv4Network | |
start = "10.0.0.0/16" | |
end = "10.9.0.0/16" | |
start_range = IPNetwork(start) | |
end_range = IPNetwork(end) | |
allowed_range = [] |
import ipaddress | |
ips = [] | |
for addr in ipaddress.IPv4Network('192.1.0.0/16'): | |
ips.append(addr) | |
for ip in ips[0:10]: | |
print(ip) |
#include <ctime> | |
#include <cstdlib> | |
// For illustrative purpose only! | |
int main() { | |
// Seed the random number generator with the current time | |
srand(time(NULL)); | |
// Generate 4 random 32-bit integers to form a UUID |
The input parameters for both functions are:
S
: the current stock priceK
: the strike price of the optionT
: the time to expiration of the option (in years)r
: the risk-free interest ratesigma
: the volatility of the stock priceExample usage:
The CSV file transaction_data.csv
contains columns for customer id, transaction id, transaction value, recency (time since last transaction), and T (time since first transaction)
# Create a sample transaction data set
transactions = pd.DataFrame({
'customer_id': [1, 2, 3, 1, 2, 1, 2, 3],
'date': pd.to_datetime(['2020-01-01', '2020-01-01', '2020-01-01', '2020-02-01', '2020-02-01', '2020-03-01', '2020-04-01', '2020-04-01']),
'amount': [100, 200, 150, 80, 120, 300, 250, 100]
})
# Calculate the customer lifetime value
clv = calculate_clv(transactions, discount_rate=0.1, retention_rate=0.8)
index = InvertedIndex()
# add some documents
index.add_document(1, "The quick brown fox")
index.add_document(2, "The quick brown dog")
index.add_document(3, "The slow brown dog")
# search for documents containing "quick brown"
result = index.search("quick brown")
class Node: | |
def __init__(self, value): | |
self.value = value | |
self.left = None | |
self.right = None | |
self.height = 1 | |
class AVLTree: | |
def __init__(self): |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
string str = "abc"; | |
sort(str.begin(), str.end()); // Sort the string in lexicographically increasing order | |
do { |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
class MaxHeap { | |
private: | |
vector<int> heap; | |
int parent(int i) { return (i - 1) / 2; } // parent index of i-th element | |
int left(int i) { return 2 * i + 1; } // left child index of i-th element |