Lab4

pdf

School

San Antonio College *

*We aren’t endorsed by this school

Course

1173

Subject

Statistics

Date

Feb 20, 2024

Type

pdf

Pages

8

Uploaded by CorporalBook6857

Report
Table of Contents Part 1: Load Data ............................................................................................................................... 1 Part 2: Create a table, displaying the average value for the listed information for each section of the cohort. .......... 1 Part 3: Create 2 Histograms in one figure (subplot), with average hours of sleep for each gender. ....................... 5 Part 4: Compare Sleep Dairy Characteristics (three ttests) .......................................................................... 7 Part 1: Load Data load diariesFall2023.mat waketime = (wakeTimes - floor(wakeTimes))*24; bedtime = (bedTimes - floor(wakeTimes))*24; hoursSleep = waketime - bedtime; totalDailySleep = hoursSleep + (minutesNap/60)-(minsAwake/60) - (toSleepMinutes/60); Part 2: Create a table, displaying the average value for the listed information for each section of the cohort. % My Personal Data's average value for each section of the cohort. % (using my Cohort Number #31 from the grade in canvas) myWaketime = waketime(:,31); myWaketimeMean = mean(myWaketime(:)); myHoursleep = hoursSleep(:, 31); myHoursleepMean = mean(myHoursleep(:)); myMinutesNapping = minutesNap(:, 31); myMinutesNappingMean = mean(myMinutesNapping(:)); mytotalDailySleep = totalDailySleep(:, 31); mytotalDailySleepMean = mean(mytotalDailySleep(:)); myBedtime = bedtime(:, 31); myBedtimeMean = mean(myBedtime(:)); mytoSleepMinutes = toSleepMinutes(:, 31); mytoSleepMinutesMean = mean(mytoSleepMinutes(:)); myMinutesAwake = minsAwake(:, 31); myMinutesAwakeMean = mean(myMinutesAwake(:)); mySSI = SSI(:, 31); mySSIMean = mean(mySSI(:)); % Section 0's average value for each section of the cohort. % Instructor section0 = section == 0; section0Waketime = waketime(:,section0); section0WaketimeMean = mean(section0Waketime(:)); section0Hoursleep = hoursSleep(:, section0); section0HoursleepMean = mean(section0Hoursleep(:)); section0MinutesNapping = minutesNap(:, section0); section0MinutesNappingMean = mean(section0MinutesNapping(:)); section0totalDailySleep = totalDailySleep(:, section0); 1
section0totalDailySleepMean = mean(section0totalDailySleep(:)); section0Bedtime = bedtime(:, section0); section0BedtimeMean = mean(section0Bedtime(:)); section0toSleepMinutes = toSleepMinutes(:, section0); section0toSleepMinutesMean = mean(section0toSleepMinutes(:)); section0MinutesAwake = minsAwake(:, section0); section0MinutesAwakeMean = mean(section0MinutesAwake(:)); section0SSI = SSI(:, section0); section0SSIMean = mean(section0SSI(:)); % Section 1's average value for each section of the cohort. section1 = section == 1; section1Waketime = waketime(:,section1); section1WaketimeMean = mean(section1Waketime(:)); section1Hoursleep = hoursSleep(:, section1); section1HoursleepMean = mean(section1Hoursleep(:)); section1MinutesNapping = minutesNap(:, section1); section1MinutesNappingMean = mean(section1MinutesNapping(:)); section1totalDailySleep = totalDailySleep(:, section1); section1totalDailySleepMean = mean(section1totalDailySleep(:)); section1Bedtime = bedtime(:, section1); section1BedtimeMean = mean(section1Bedtime(:)); section1toSleepMinutes = toSleepMinutes(:, section1); section1toSleepMinutesMean = mean(section1toSleepMinutes(:)); section1MinutesAwake = minsAwake(:, section1); section1MinutesAwakeMean = mean(section1MinutesAwake(:)); section1SSI = SSI(:, section1); section1SSIMean = mean(section1SSI(:)); % Section 2's average value for each section of the cohort. section2 = section == 2; section2Waketime = waketime(:,section2); section2WaketimeMean = mean(section2Waketime(:)); section2Hoursleep = hoursSleep(:, section2); section2HoursleepMean = mean(section2Hoursleep(:)); section2MinutesNapping = minutesNap(:, section2); section2MinutesNappingMean = mean(section2MinutesNapping(:)); section2totalDailySleep = totalDailySleep(:, section2); section2totalDailySleepMean = mean(section2totalDailySleep(:)); section2Bedtime = bedtime(:, section2); section2BedtimeMean = mean(section2Bedtime(:)); section2toSleepMinutes = toSleepMinutes(:, section2); section2toSleepMinutesMean = mean(section2toSleepMinutes(:)); section2MinutesAwake = minsAwake(:, section2); section2MinutesAwakeMean = mean(section2MinutesAwake(:)); section2SSI = SSI(:, section2); section2SSIMean = mean(section2SSI(:)); % Section 3's average value for each section of the cohort. section3 = section == 3; section3Waketime = waketime(:,section3); section3WaketimeMean = mean(section3Waketime(:)); section3Hoursleep = hoursSleep(:, section3); section3HoursleepMean = mean(section3Hoursleep(:)); 2
section3MinutesNapping = minutesNap(:, section3); section3MinutesNappingMean = mean(section3MinutesNapping(:)); section3totalDailySleep = totalDailySleep(:, section3); section3totalDailySleepMean = mean(section3totalDailySleep(:)); section3Bedtime = bedtime(:, section3); section3BedtimeMean = mean(section3Bedtime(:)); section3toSleepMinutes = toSleepMinutes(:, section3); section3toSleepMinutesMean = mean(section3toSleepMinutes(:)); section3MinutesAwake = minsAwake(:, section3); section3MinutesAwakeMean = mean(section3MinutesAwake(:)); section3SSI = SSI(:, section3); section3SSIMean = mean(section3SSI(:)); % Section 4's average value for each section of the cohort. section4 = section == 4; section4Waketime = waketime(:,section4); section4WaketimeMean = mean(section4Waketime(:)); section4Hoursleep = hoursSleep(:, section4); section4HoursleepMean = mean(section4Hoursleep(:)); section4MinutesNapping = minutesNap(:, section4); section4MinutesNappingMean = mean(section4MinutesNapping(:)); section4totalDailySleep = totalDailySleep(:, section4); section4totalDailySleepMean = mean(section4totalDailySleep(:)); section4Bedtime = bedtime(:, section4); section4BedtimeMean = mean(section4Bedtime(:)); section4toSleepMinutes = toSleepMinutes(:, section4); section4toSleepMinutesMean = mean(section4toSleepMinutes(:)); section4MinutesAwake = minsAwake(:, section4); section4MinutesAwakeMean = mean(section4MinutesAwake(:)); section4SSI = SSI(:, section4); section4SSIMean = mean(section4SSI(:)); % Section 5's average value for each section of the cohort. section5 = section == 5; section5Waketime = waketime(:,section5); section5WaketimeMean = mean(section5Waketime(:)); section5Hoursleep = hoursSleep(:, section5); section5HoursleepMean = mean(section5Hoursleep(:)); section5MinutesNapping = minutesNap(:, section5); section5MinutesNappingMean = mean(section5MinutesNapping(:)); section5totalDailySleep = totalDailySleep(:, section5); section5totalDailySleepMean = mean(section5totalDailySleep(:)); section5Bedtime = bedtime(:, section5); section5BedtimeMean = mean(section5Bedtime(:)); section5toSleepMinutes = toSleepMinutes(:, section5); section5toSleepMinutesMean = mean(section5toSleepMinutes(:)); section5MinutesAwake = minsAwake(:, section5); section5MinutesAwakeMean = mean(section5MinutesAwake(:)); section5SSI = SSI(:, section5); section5SSIMean = mean(section5SSI(:)); % The Average Values for Each Section of the Cohort Table fprintf( ' MyData\t Section0\t Section 1\t Section 2\t Section 3\t Section 4\t Section 5\n' ); 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
fprintf( 'Wake Up time: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t %8.2f\n' , myWaketimeMean, section0WaketimeMean, section1WaketimeMean, section2WaketimeMean, section3WaketimeMean, section4WaketimeMean, section5WaketimeMean); fprintf( 'Bed Time: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f \t%8.2f\n' , myBedtimeMean, section0BedtimeMean, section1BedtimeMean, section2BedtimeMean, section3BedtimeMean, section4BedtimeMean, section5BedtimeMean); fprintf( 'Hours in Bed: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t %8.2f\n' , myHoursleepMean, section0HoursleepMean, section1HoursleepMean, section2HoursleepMean, section3HoursleepMean, section4HoursleepMean, section5HoursleepMean); fprintf( 'Minutes to Sleep: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t %8.2f\t%8.2f\n' , mytoSleepMinutesMean, section0toSleepMinutesMean, section1toSleepMinutesMean, section2toSleepMinutesMean, section3toSleepMinutesMean, section4toSleepMinutesMean, section5toSleepMinutesMean); fprintf( 'Minutes to Napping: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t %8.2f\t%8.2f\n' , myMinutesNappingMean, section0MinutesNappingMean, section1MinutesNappingMean, section2MinutesNappingMean, section3MinutesNappingMean, section4MinutesNappingMean, section5MinutesNappingMean); fprintf( 'Awake at Night: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f \n' , myMinutesAwakeMean, section0MinutesAwakeMean, section1MinutesAwakeMean, section2MinutesAwakeMean, section3MinutesAwakeMean, section4MinutesAwakeMean, section5MinutesAwakeMean); fprintf( 'Total Daily Sleep: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t %8.2f\t%8.2f\n' , mytotalDailySleepMean, section0totalDailySleepMean, section1totalDailySleepMean, section2totalDailySleepMean, section3totalDailySleepMean, section4totalDailySleepMean, section5totalDailySleepMean); fprintf( 'SSI: %8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t%8.2f\t %8.2f\n' , mySSIMean, section0SSIMean, section1SSIMean, section2SSIMean, section3SSIMean, section4SSIMean, section5SSIMean); MyData Section0 Section 1 Section 2 Section 3 Section 4 Section 5 Wake Up time: 8.22 6.16 8.40 9.18 8.52 8.58 8.74 Bed Time: -1.07 -1.46 0.18 0.90 0.50 0.39 0.29 Hours in Bed: 9.29 7.61 8.23 8.28 8.02 8.19 8.45 Minutes to Sleep: 32.38 4.05 18.57 17.57 16.36 19.11 12.05 Minutes to Napping: 48.57 10.45 9.72 11.01 19.02 17.31 9.39 Awake at Night: 1.67 5.86 6.58 19.99 11.00 6.60 4.75 Total Daily Sleep: 9.53 7.62 7.97 7.84 7.88 8.05 8.32 SSI: 2.90 2.93 2.74 2.67 2.82 2.70 3.04 4
Part 3: Create 2 Histograms in one figure (sub- plot), with average hours of sleep for each gen- der. FemaleLogical = strcmpi(gender, 'Female' ); MaleLogical = strcmpi(gender, 'Male' ); hoursSleepFemale = hoursSleep(:,FemaleLogical); AverhoursSleepFemale = mean(hoursSleepFemale,2); hoursSleepMale = hoursSleep(:,MaleLogical); AverhoursSleepMale = mean(hoursSleepMale,2); figure; subplot(1, 2, 1); histogram(AverhoursSleepFemale, 10); title( 'Average Hours of Sleep for Females' ); xlabel( 'Hours Slept' ); ylabel( 'Number of Times Slept' ); legend( 'Females' ); subplot(1, 2, 2); histogram(AverhoursSleepMale, 10); title( 'Average Hours of Sleep for Males' ); xlabel( 'Hours Slept' ); ylabel( 'Number of Times Slept' ); legend( 'Males' ); 5
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Part 4: Compare Sleep Dairy Characteristics (three ttests) Students = section1 | section2 | section3 | section4 | section5; Instructor = section0; StudentsWaketime = waketime(:,Students); StudentsHoursSleep = hoursSleep(:,Students); %Do I and section 2 have the same average waketime? [h1, p1, c1] = ttest2(myWaketime(:), section2Waketime(:)); fprintf( 'Do I and section 2 have the same average waketime?\n' ); fprintf( 'The hypothesis is %4.2f, The p-value is %4.2f, and the confidence interval is [%4.2f] to [%4.2f] \n' , h1, p1, c1); %Does the Instructor and the Students have the same average Hours of Sleep? [h2, p2, c2] = ttest2(section0Hoursleep(:), StudentsHoursSleep(:)); fprintf( 'Does the Instructor and the Students have the same average Hours of Sleep?\n' ); fprintf( 'The hypothesis is %4.2f, The p-value is %4.2f, and the confidence interval is [%4.2f] to [%4.2f] \n' , h2, p2, c2); 7
%Does section 4 and section 5 have the same average bedtime? [h3, p3, c3] = ttest2(section4Bedtime(:), section5Bedtime(:)); fprintf( 'Does section 4 and section 5 have the same average bedtime?\n' ); fprintf( 'The hypothesis is %4.2f, The p-value is %4.2f, and the confidence interval is [%4.2f] to [%4.2f] \n' , h3, p3, c3); Do I and section 2 have the same average waketime? The hypothesis is 1.00, The p-value is 0.04, and the confidence interval is [-1.86] to [-0.06] Does the Instructor and the Students have the same average Hours of Sleep? The hypothesis is 0.00, The p-value is 0.06, and the confidence interval is [-1.22] to [0.03] Does section 4 and section 5 have the same average bedtime? The hypothesis is 0.00, The p-value is 0.32, and the confidence interval is [-0.09] to [0.28] Published with MATLAB® R2023a 8