Introduction to Mathematica (2013)

MATHEMATICA created by Steven Wolfram, a product of Wolfram Research, Inc. Mathematica is available for different operating systems, such as SGI, Sun, NeXT, Mac, DOS, and Windows. This introduction to Mathematica will help you to understand its use as a mathematical and programming language with numerical, symbolic, and graphical calculations.

Introduction to Mathematica

  1. A calculator for arithmetic, symbolic, and algebraic calculations
  2. A language for developing transformation rules, so that general mathematical relationships can be expressed
  3. An interactive environment for the exploration of numerical, symbolic, and graphical calculations
  4. A tool for preparing input to other programs, or to process output from other programs

Getting Started with Mathematica

Starting Mathematica will open a fresh window or a notebook, where we do all mathematical calculations and some graphics. Initially window’s title is “untitled-1” which can be changed after saving the notebook by name as desired. Mathematica notebook with text, graphics, and Mathematica input and output

Introduction to mathematica notebook

Entering Expressions

Type 1+1 in the notebook and press the ENTER key from the keyboard. You will get an answer in the next line of work area. This is called evaluating or entering the expression. Note that Mathematica places “In[1]:=” and “out[1]=” (without quotation marks) labels to 1+1 and 2 respectively. You will also see a set of brackets on the right side of the input and output. The innermost brackets enclose the input and output while the outer bracket (larger bracket) groups the input and output. Each bracket contains a cell. Each time you enter or change the input you will notice that the “In” and “Out” labels will also be changed.

Basic Arithmetic

Mathematica can perform basic operations of additions (+), subtraction (-), multiplication (*), division (/), exponentiation(^), etc. For example, write the following line for basic arithmetic in Mathematica

2*3+4^2
5*6
2(3+4)
(2-3+1)(1+2/3)-5^(-1)
6!

Using Previous Results in Mathematica

Often we need the output of the first (previous) calculations in our next (coming) computation. For this purpose % symbol can be used to refer to the output of the previous cell. For example,

2^5
% + 100

Here 2^5 is added in 100.

%% refers to the result before the last results (2nd last).

Exact vs Approximation

Mathematica can give approximate results; when we need

3^20/2^21 produces $\frac{3486784401}{2097152}$

We can force Mathematica to approximate results in decimals by putting decimals in expressions (with any digit or number) such as

3.0^20/ 2^21

For a decimal in number in an expression, Mathematica considers it to be an approximation rather than an exact number.

Wolfram Mathematica

R Frequently Asked Questions

Matlab as a Calculator

MATLAB stands for “Matrix Laboratory” and is an interactive, matrix-based system and fourth-generation programming language from Mathworks Inc., which is mathematics software. Matlab helps to perform statistical analysis and gives the user complete freedom to implement specific algorithms and perform complex custom-tailored operations.

Matlab has a command-driven approach. Commands with appropriate arguments are written after the Matlab command prompt >>. The Matlab program provides the user with a convenient environment for performing many types of calculations. This introduction to Matlab will help users understand its importance and variety of applications in different scientific fields.

Matlab as a Calculator

Matlab has three primary windows.

1) Command windows
2) Graphics Windows
3) Edit Windows used to write M-Files

The common way to operate Matlab is to enter commands in the command window.

Matlab as a Calculator

>> 55 – 16
ans = 39
>> ans + 11
ans =50

Matlab assigns the results ans whenever you do not explicitly assign the calculations to a chosen variable.

>> a = 4                   % assigns a scalar quantity to a
>> a                         % Prints the scalar quantity in command windows
>> a = 4                   % suppressed echo printing
>> a =4; A=6; x=1;  % multiple variable definition

Note: Matlab treats names as Case-Sensitive.

>> format long
>> pi
>> format short
>> pi
Matlab as Calculator

Learn R Programming Language

Independent Samples t test in SPSS

Introduction (Independent Samples t test using SPSS)

Independent Samples t test is a test for independent groups and is useful when the same variable has been measured in two independent groups and the researcher wants to know whether the difference between group means is statistically significant. “Independent groups” means that the groups have different people in them and that the people in the different groups have not been matched or paired in any way.

Objectives of Independent Samples t test

The independent t-test compares the means of two unrelated/independent groups measured on the Interval or ratio scale. The SPSS t-test procedure allows the testing of the hypothesis when variances are assumed to be equal or when are not equal and also provides the t-value for both assumptions. This test also provides the relevant descriptive statistics for both of the groups.

Assumptions (Independent Samples t test)

  • Variable can be classified into two groups independent of each other.
  • The variable is Measured on an interval or ratio scale.
  • The measured variable is approximately normally distributed
  • Both groups have similar variances  (variances are homogeneity)

Data Required for (Independent Samples t test)

Suppose a researcher wants to discover whether left and right-handed telephone operators differed in the time it took them to answer calls. The data for reaction time were obtained (RT’s measured in seconds):

Data Telephone: Independent Samples t test

The mean reaction times suggest that the left-handers were slower but does a t-test confirm this?

Independent Samples t Test using SPSS

Perform the following steps to perform the Independent Samples t-test by using the SPSS and entering the data set in the SPSS data view

1) Click Analyze > Compare Means > Independent-Samples T Test… on the top menu as shown below.

Independent Samples t test in SPSS

2) Select continuous variables that you want to test from the list.

independent samples t test - 2

3) Click on the arrow to send the variable in the “Test Variable(s)” box. You can also double-click the variable to send it in the “Test Variable” Box.

4) Select the categorical/grouping variable so that group comparison can be made and send it to the “Grouping Variable” box.

5) Click on the “Define Groups” button. A small dialog box will appear asking about the name/code used in the variable view for the groups. We used 1 for males and 2 for females. Click the Continue button when you’re done. Then click OK when you’re ready to get the output.  See the Pictures for a Visual view.

independent samples t test - Define groups 3

Independent Samples t-test SPSS Output

independent samples t test - SPSS Output 4

The first Table in the output is about descriptive statistics concerning your variables. The number of observations, mean, variance, and standard error are available for both of the groups (male and female)

The second Table in the output is an important one concerning the testing of the hypothesis. You will see that there are two t-tests. You have to know which one to use. When comparing groups having approximately similar variances use the first t-test. Levene’s test checks for this. If the significance for Levene’s test is 0.05 or below, then it means that the “Equal Variances Not Assumed” test should be used (the second one), Otherwise use the “Equal Variances Assumed” test (first one).  Here the significance is 0.287, so we’ll be using the “Equal Variances” first row in the second table.

In the output table “t” is the calculated t-value from test statistics, for example, the t-value is 1.401

df stands for degrees of freedom, in the example, we have 18 degrees of freedom

Sig (two-tailed) means two-tailed significance value (P-Value), for example, the sig value is greater than 0.05 (significance level).

Decision

As the P-value of 0.178 is greater than our 0.05 significance level we fail to reject the null hypothesis. (two-tailed case)

As the P-value of 0.089 is greater than our 0.05 significance level we fail to reject the null hypothesis. (one tail case with 0.05 significance level)

As the P-value of 0.089 is smaller than our 0.10 significance level we reject the null hypothesis and accept the alternative hypothesis. (one tail case with 0.10 significance level). In this case, it means that the left handler has a slower reaction time as compared to the right handler on average.

Other links to study Independent Samples t-test using SPSS

  • https://libguides.library.kent.edu/SPSS/IndependentTTest
  • https://statistics.laerd.com/spss-tutorials/independent-t-test-using-spss-statistics.php

R Programming Language Frequently Asked Questions