Pygame

Gamming is one the hottest fields out there today and people are going crazy when it comes to gaming. With the emerging field of gamming, game programming is also growing nowdays and since it has a wide range of application in almost every field like advertising,education,AI/ML etc., programmers are really into it. Building a game for any purpose is fun and has it’s own craze since it involves a lot of imagination. Seeing your imagination and design being build has its own satisfaction. Pygame is python open source framework which helps you do so. 

What is Pygame?

If we talk about the basic well-known definition of Pygame, it says-

“Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language.”

You can also define Pygame as-

“Pygame is a Python wrapper module for the SDL multimedia library. It contains python functions and classes that will allow you to use SDL’s support for playing cdroms, audio and video output, and keyboard, mouse and joystick input.”

What this basically means that if you know python and you love playing games,you will definitely have an instinct to develop it and Pygame is one of the easiest python modules that’ll help you in that.It was an open source project which has developed a lot today and is a very popular module for beginners.

It is third party module that you can download from the internet that is used to make games using python. The games are pretty simple and most of them are 2D games.You draw shapes and images and you can go pretty far with Pygame if you know how to use it proficiently .

How to work with Pygame?

To begin with Pygame module,you need to follow some easy steps as mentioned below:-

  1. You must have Python installed in your pc/mac. If you don’t have it you can easily download it from Python Webiste: https://www.python.org/. Just download the latest version of python available.
  2. Then you have to open command prompt window.
  • In the command prompt window, type “pip” and then type “pip install pygame” to install the module.pip is pretty much package install in python.
  • After that pip command will help collecting everything and then you have pygame installed in your pc/mac.
  • You can uninstall  pygame by typing “pip uninstall pygame” in command prompt.
  • If it dosen’t work for you that means you do not have python environment variables which you can fix easily and then get started with pygame.

Working in pygame

The module Pygame is very easy to learn and use so for a beginner it becomes simple to get started with game development. Python itself is very easy to understand language compared to others and even non-programmer can read it whats written in python because its syntax is more of general language. Pygame is built on python so you can explore amazing features of game development using pygame easily. So,to begin with pygame open python cmd and type “import pygame” and then type “pygame .int()”. This will let you import pygame module so that you can work with it. 

Building your own games

Pygame module helps you to bring your imagination of gaming to life. Being a beginner in this field, it becomes very difficult to work with complex codes. But using pygame and following the step wise approach, you can really build your own amazing games. Let us look how we can do it.

Firstly, we have to set up window according to what game design we have in our mind and then according to one’s requirement you can have your own specifications. To create a window, just type “win=pygame.display.set_model((1000,1000))”.What this basically so is, it will create a pygame window wherein your whole game program will work.

You can give caption to the window, create shapes, images and much more depending upon how creative you can be while building a game. You can create your character with the help of pygame and the let it move by specifying attributes like size, velocity, sound and music effects etc. Sound exciting, Right ! But this isn’t all. You can also have animation and optimization done to give your game a look according to you.  

The game Dangerous Higschool Girls In Trouble was written in Pygame and has won some awards and is available on steam. There are many such games beautifully built using pygame. So, if you want to jump into game development and don’t know where to begin with, Pygame is the best available option.

INTRODUCTION TO ANOVA FOR DATA SCIENCE(With COVID-19 case study using python)

By: Sneka. P

 

We are grappling with a pandemic that’s operating at a never-before-seen scale. Researchers all over the globe and frantically trying to develop a vaccine or a cure for COVID-19 while doctors are just keeping the pandemic from overwhelming the entire world.

So let’s consider a situation where doctors have four medical treatments to apply to cure the patients. Once we have the test results, one approach is to assume that the treatment which took the least time to cure the patients is the best among them. But what if some of these patients had been partially cured already, or if any other medication was already working on them?

In this article, let me initiate the ANOVA test and its different types that are being used to make better decisions. So I’ll demonstrate each type of ANOVA test in python to visualize how they work on covid-19 data. So let’s get going

WHAT IS ANOVA TEST?

An Analysis of Variance test, or ANOVA, can be thought of as a generalization of the t-test for more than 2 groups. The independent t-test is used to differentiate means of a situation between two groups. ANOVA is used when we want to compare the means of a condition between more than two groups.

ANOVA tests if there is a difference in the mean somewhere in the model, but it does not tell us where the difference is (if there is one). To find where the difference among the groups, we have to conduct the post-hoc tests.

To perform any tests, we first need to define the null and alternate hypothesis:

  • NULL HYPOTHESIS: There is no significant difference between the groups.
  • ALTERNATE HYPOTHESIS: There is significant difference between the groups. 

Basically, ANOVA is performed by comparing two types of variation, the variation between the sample means, as well as the variation within each of the samples. The below mentioned formula represents one-way Anova test.  The formula is given below.

Assumptions of an ANOVA Test

There are certain assumptions we need to make before performing ANOVA:

  1. The observation are obtained independently and randomly from the population defined by the factor levels.
  2. The data for each factor level is normally distributed.
  3. Independence of cases: the sample cases should be independent of each other.
  4. Homogeneity of variance: Homogeneity means that the variance among the groups should be approximately equal.

The premise of homogeneity of variance can be tested using tests such as Levene’s test or the brown-Forsythe test. Normality of the distribution of the scores can be tested using histograms, the values of skewness and kurtosis, or using tests such as Shapiro or q-q- plot. 

The assumption of independence can be determined from the design of the study. It is important to note that ANOVA is not robust to violations to the assumptions of independence. This is to say that even if you violate the premise of homogeneity or normality you can perform the test and basically trust findings.

However, the results of ANOVA are invalid if the indecency assumption is violated. In general, with violation of homogeneity, the analysis is considered robust if you have equal-sized groups. With violations of normality, continuing with ANOVA is generally ok if you have a large sample size.

Types of ANOVA Tests:

  1. One-way ANOVA:  It has just one independent variable.
  • For e.g : differences in corona cases can be assessed by country, and a country can have 2, 20 or more different categories to compare.
  1. Two-way ANOVA: A two- way anova(also called factorial ANOVA) refers to an ANOVA using two independent variables
  • For e.g: old age group may have higher corona cases overall compared to the Young Age group, but this difference could be greater (or less) in Asian countries compared to European countries.
  1. N-way ANOVA:   A researcher can also use more than two independent variables, and this is an n-way ANOV (with n being the number of independent variables) 
  • For e.g: potential differences in corona cases can be examined by country, gender, age, group, ethnicity etc.

WITH REPLICATION (VS) WITHOUT REPLICATION

  1. Two-way ANOVA with replication: Two groups and the members of those groups are doing more than one thing 
  • For e.g: let’s say a vaccine has not been developed for covid-19, and doctors are trying two different treatments to cure two groups of covid-19 infected patients
  1. Two-way ANOVA without replication: Its used when you only have one group and you are double-testing that same group 
  • For e.g: let’s say a vaccine has been developed for covid-19, and researchers are testing one set of volunteers before and after they have been vaccinated to see if it works or not.
  1. POST-ANOVA Test
  • When we conduct an ANOVA, we are attempting to determine if there is a statically significant difference between the groups. If we find that there is a difference, we will then need to examine where the group differences lay.

So this is the end I have tried to explain the ANOVA test using a relevant case study in these pandemic times. It was fun experience putting this all together for our community!