Tuesday, November 29, 2022

Install VirtualBox 7 on Fedora 37 Server via rpmfusion repository

To make system ready for VitualBox 7 setup via rpmfusion repos,

install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system.  The distribution package containing the headers is probably: kernel-devel-6.0.9-300.fc37.x86_64.  Kernel packages installation has been done as follows.

[boris@Server37fedora ~]$ rpm -qa | grep kernel | grep 6.0.9

kernel-core-6.0.9-300.fc37.x86_64

kernel-modules-6.0.9-300.fc37.x86_64

kernel-devel-6.0.9-300.fc37.x86_64

kernel-devel-matched-6.0.9-300.fc37.x86_64

kernel-6.0.9-300.fc37.x86_64

Setup rpmfusion :-

$ sudo dnf install   \ 

https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm 

$ sudo dnf    \     

install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

$ sudo dnf install VirtualBox kernel-devel-$(uname -r) akmod-VirtualBox

$ sudo akmods

$ sudo systemctl restart vboxdrv 

$ lsmod  | grep -i vbox

[boris@Server37fedora ~]$ lsmod  | grep -i vbox

vboxnetadp             28672  0

vboxnetflt             32768  0

vboxdrv               577536  2 vboxnetadp,vboxnetflt

Download  VBoxGuestAdditions_7.0.4.iso  link https://w0.dk/~chlor/vboxguestadditions/

















After Guest setup shutdown guest and mount VBoxGuestAdditions_7.0.4.iso  via GUI of VitualBox 7 

Reboot guest and 

$ sudo mount /dev/sr0 /media

inside Vbox's VM































Thursday, September 22, 2022

Wednesday, August 3, 2022

Verification CLT via flask && matplotlib

 Central limit theorems (CLT) are a class of theorems in probability theory stating that the sum of a sufficiently large number of weakly dependent random variables that have approximately the same scale (none of the terms dominates, does not make a decisive contribution to the sum), has a distribution close to normal. Since many random variables in applications are formed under the influence of several weakly dependent random factors, their distribution is considered normal. In this case, the condition must be observed that none of the factors is dominant. Central limit theorems in these cases justify the application of the normal distribution.

Following below is python code to be run by flask framework

(.env) boris@boris-All-Series:~/flaskmatplotlib$ cat  flaskMatplotlib7.py

import io

from flask import Response

from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas

from matplotlib.figure import Figure

from flask import Flask

import matplotlib.pyplot as plt

import numpy as np

import scipy.stats as stats


plt.rcParams["figure.figsize"] = [14.50, 10.50]

plt.rcParams["figure.autolayout"] = True

app = Flask(__name__)

@app.route('/print-plot')

def plot_png():

   fig = Figure()

   axes = fig.add_subplot(1, 1, 1)

   axes.set_title('CLT via flask&&matplotlib, Refresh Screen a couple of times',fontsize = 15, color = 'black')


   n = 10000

   avg = []

   for i in range(1,n):

       a = np.random.randint(1,7,10)

       avg.append(np.average(a))

   # Normalise this histogram too

   axes.hist(avg[0:], 20, density=True, stacked=True)


   avg1 = []

   for i in range(1,n):

       a = np.random.randint(1,7,10)

       avg1.append(np.average(a))

   # Normalise this histogram too

   axes.hist(avg1[0:], 20, density=True, stacked=True)

   avg2 = []

   for i in range(1,n):

       a = np.random.randint(1,7,10)

       avg2.append(np.average(a))

   # Normalise this histogram too

   axes.hist(avg2[0:], 20, density=True, stacked=True)

   avg3 = []

   for i in range(1,n):

       a = np.random.randint(1,7,10)

       avg3.append(np.average(a))

   # Normalise this histogram too

   axes.hist(avg3[0:], 20, density=True, stacked=True)

   zscore = stats.zscore((avg[0:]+avg1[0:]+avg2[0:]+avg3[0:]))

   mu, sigma = np.mean(avg+avg1+avg2+avg3), np.std(avg+avg1+avg2+avg3)

   s = np.random.normal(mu, sigma, 10000)

   # Create the bins and histogram

   count, bins, ignored = axes.hist(s, 20, density=True, stacked=True) 

   # Use scipy.stats implementation of the normal pdf

   # Plot the distribution curve

   x = np.linspace(1.5, 5.5, num=100)

   axes.plot(x, stats.norm.pdf(x, mu, sigma))

   output = io.BytesIO()

   FigureCanvas(fig).print_png(output)

   return Response(output.getvalue(), mimetype='image/png')

$  export FLASK_ENV=development

$  export FLASK_DEBUG=1

$  export FLASK_APP=flaskMatplotlib7.py

(.env) boris@boris-All-Series:~/flaskmatplotlib$ flask run

WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

 * Serving Flask app 'flaskMatplotlib7.py'

 * Debug mode: on

 * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)

 * Restarting with stat

 * Debugger is active!

 * Debugger PIN: 452-793-879





























Another version of python code. Just looping when creating histograms.

(.env) boris@boris-All-Series:~/flaskmatplotlib$ cat flaskMatplotlib10.py
import io
from flask import Response
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from flask import Flask
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import warnings
warnings.filterwarnings('ignore')

plt.rcParams["figure.figsize"] = [15.50, 11.50]
plt.rcParams["figure.autolayout"] = True
app = Flask(__name__)
@app.route('/print-plot')
def plot_png():
   fig = Figure()
   axes = fig.add_subplot(1, 1, 1)
   axes.set_title('Verification CLT via flask&&matplotlib, Refresh Screen a couple of times',fontsize = 15, color = 'black')

   n = 10000
   longlst = []
   sigmalst = []
   lst = ["avg","avg1","avg2","avg3"]
   for avs in lst:
       avs = [] 
       for i in range(1,n):
         a = np.random.randint(1,7,10)
         avs.append(np.average(a))
       # Normalise this histogram too
       axes.hist(avs[0:], 20, density=True, stacked=True)
       longlst = longlst + avs[0:]
       sigmalst = sigmalst + avs[:]

   zscore = stats.zscore(longlst)

   mu, sigma = np.mean(sigmalst), np.std(sigmalst)

   s = np.random.normal(mu, sigma, 10000)
   # Create the bins and histogram
   count, bins, ignored = axes.hist(s, 20, density=True, stacked=True) 
   # Use scipy.stats implementation of the normal pdf
   # Plot the distribution curve
   x = np.linspace(1.5, 6.5, num=100)
   axes.plot(x, stats.norm.pdf(x, mu, sigma))

   output = io.BytesIO()
   FigureCanvas(fig).print_png(output)
   return Response(output.getvalue(), mimetype='image/png')

(.env) boris@boris-All-Series:~/flaskmatplotlib$ flask run
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Serving Flask app 'flaskMatplotlib10.py'
 * Debug mode: on
 * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 255-673-976
  



Tuesday, June 7, 2022

Plotting Pandas Dataframe been sorted by coulmn of date type on F36

Both columns on the plot are not of numeric type, however directives

plt.plot(dfs['AdmissionDate'], dfs['Name'])
plt.xticks(rotation='vertical')
plt.show() 

allow to plot desired picture via standard mathplotlib commands

(.env) boris@boris-All-Series:~/MATPLOTLIBSR/TENSOR$ cat SortedPandasD1.py

# importing package
import pandas as pd
import matplotlib.pyplot as plt
 
# Creating a dataframe that stores records of students taking admission in a college
data = pd.DataFrame({'AdmissionDate': ['2021-01-25','2021-01-22','2021-01-20',
              '2021-01-18','2021-01-22','2021-01-17','2021-01-21'],
              'StudentID': [7,5,3,2,6,1,4],
              'Name': ['Ram','Shyam','Mohan','Sohan','Lucky','Abhinav','Danny'],
              'Stream':['CSE','ECE','Civil','Mechanical','CSE','IT','EEE']
                   })
# Checking dataframe
print(data)
print('\n')

dfs = data.sort_values(by='AdmissionDate', ascending=True)
print(dfs)

plt.plot(dfs['AdmissionDate'], dfs['Name'])
plt.xticks(rotation='vertical')

plt.show()






















Sunday, April 17, 2022

Install KVM on Ubuntu Jammy Jellyfish (Development branch)

 First run

$ sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager

Enable and start daemon libvirtd

$ sudo usermod -aG libvirt $USER
$ sudo usermod -aG kvm $USER

Set up WebCocpit Console 
 $ sudo vi  /etc/apt/sources.list
Add line
deb http://archive.ubuntu.com/ubuntu \
focal-backports main restricted universe multiverse
:wq
 $ sudo apt-get update
$ sudo apt install firewalld
$ sudo systemctl start firewalld
$ sudo systemctl enable firewalld
$ sudo systemctl status firewalld
$ sudo apt-get install -t focal-backports cockpit
$ sudo apt install -t focal-backports cockpit-machines
$ sudo systemctl start cockpit.socket
$ sudo systemctl status cockpit.socket
$ sudo systemctl enable cockpit.socket
$ sudo firewall-cmd --add-service=cockpit --permanent
$ sudo firewall-cmd --reload

 




KVM Hypervisor Host