Skip to content

Instantly share code, notes, and snippets.

View sallos-cyber's full-sized avatar

Dr. I. Markelic sallos-cyber

View GitHub Profile
@sallos-cyber
sallos-cyber / plot_bivariate_normal.py
Created March 7, 2025 08:38
Visualize how the covariance matrix affects the bivariate normal distribution (BVN) by creating a pretty plot of a BVN with a custom covariance.
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal
def plot_bivariate_normal(covmat, filename, x_range=(-4, 4), y_range=(-4, 4), grid_size=100):
"""
Plots the bivariate normal distribution in both 3D and top view.
Parameters:
- covmat: Covariance matrix for the bivariate normal distribution.
@sallos-cyber
sallos-cyber / SimulateBVN.py
Created February 25, 2025 14:16
BVN from two iid standard normals
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D
# Step 1: Define the parameters
rho = 0 # Correlation coefficient
n_samples = 100000 # Number of samples to generate
# Step 2: Generate independent standard normal variables
@sallos-cyber
sallos-cyber / gradient_descent_with_keras.ipynb
Last active December 4, 2024 15:21
gradient descent with keras
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sallos-cyber
sallos-cyber / gradient_descent_tensorflow.ipynb
Last active December 4, 2024 15:19
gradient descent with tensorflow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sallos-cyber
sallos-cyber / anwers_to_programming_questions_markelic.ipynb
Created March 6, 2024 16:32
Answers to programming questions "probabl"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sallos-cyber
sallos-cyber / Beta_Using_Uniforms.ipynb
Created June 21, 2023 08:50
Create a random variable with a Beta distribution using only draws from the Uniform distribution
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sallos-cyber
sallos-cyber / pyspark_streaming_from_and_to_file.py
Created April 8, 2022 08:40
Pyspark streaming from and to file
from pyspark.sql.functions import explode
from pyspark.sql.functions import split
from pyspark.streaming import StreamingContext
from pyspark.sql import SparkSession
import time
spark = SparkSession.builder \
.appName('Streaming') \
.getOrCreate()
@sallos-cyber
sallos-cyber / server.js
Created March 20, 2022 14:40
to use node.js as http server
const express = require('express')
const path = require('path')
const httpPort = 1026
const app = express()
app.use(express.static(path.join(__dirname, './')))
app.get('/', function(req, res) {
def callPreprocessData(fn='/home/someusr/Downloads/flows.csv'):
data=pd.read_csv(fn)
print(data.head(3))
data['Bytes']=data['Bytes'].fillna(0)
data['Bytes']=data['Bytes'].astype(str)
#silly nfdump writes bytes as integer but sometimes it converts it to
#mb. The following finds those entries and converts them into bytes.
data.loc[data['Bytes'].str.contains('M'),'Bytes'] = data[data['Bytes'].str.contains('M')]['Bytes'].apply(lambda x: float(x[1:-2])*1024*1024)
data['Bytes']=data['Bytes'].astype(int)