| Server IP : 172.64.80.1 / Your IP : 172.70.131.126 Web Server : Apache System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64 User : federalpolyede.edu.ng_idh35skikv ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/federalpolyede.edu.ng/phd_code/ |
Upload File : |
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Reading From Excel Files
# df = pd.read_excel('c:/myData/PhD/code/Attackintesity_3.xlsx')
df = pd.read_excel('c:/myData/PhD/code/attack_sample.xlsx')
#print(df.loc[df['sn']>0,['intensity']])
arr = eval(df.to_json())
for i in range(len(arr['intensity'])):
intensity = arr['intensity'][str(i)]
# Assuming there are two players and three strategies for each player
# Number of simulations or iterations
attack_count_0=0
attack_count_1=0
attack_count_2=0
defend_count_0=0
defend_count_1=0
defend_count_2=0
chosen_strategies=[]
# Simulate strategies
num_simulations=len(arr['intensity'])
for i in range(len(arr['intensity'])):
chosen_strategy = arr['intensity'][str(i)]
# chosen_strategies.append(chosen_strategy)
if (chosen_strategy==0):
attack_count_0+=1
if (chosen_strategy==1):
attack_count_1+=1
if (chosen_strategy==2):
attack_count_2+=1
# print("Chosen Strategies:", chosen_strategy)
# print(chosen_strategies[0],chosen_strategies[-1])
#indices = max(enumerate(chosen_strategies), key=lambda x: x[1])[0]
# print(indices)
attack_0=attack_count_0/num_simulations
attack_1=attack_count_1/num_simulations
attack_2=attack_count_2/num_simulations
# attack_0 = f"{attack_0:.2f}"
print("================================================")
print("Probability Distibution from Field Data")
print("================================================")
print(" No Attack",f"{attack_0:.2f}","\n","Low Intensity Attack",f"{attack_1:.2f}","\n","High Intensity Attack",f"{attack_2:.2f}")