PHYS 1655 (python) - Quiz 3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/43

flashcard set

Earn XP

Description and Tags

44 Terms

1
New cards

Parts of a Histogram

Range, number of bins, number of total entries, number of entries in each bin, number outside range

2
New cards

Why are histograms so useful?

Histograms can reduce large quantities of data into a manageable summary.

3
New cards

When can you trust numerical probablities?

-the quantity of interest has been correctly measured

-size of error has been correctly calculated

4
New cards

What is Chi-Square and what is it used for?

-used to compare models, to see which is more likely to produce the observed data

-measures the collective deviation of the data points from the model, and the model that produces the smallest chi-squared value is the most consistent with the data

5
New cards

Degree of freedom (k)

1 data point = 1 degree of freedom

As the number of degrees of freedom gets larger, the chi-square distribution approaches a Gaussian/Normal shape

6
New cards

What are reduced chi-square values and when do you use them?

-used when comparing chi-square values with different degrees of freedom

-is chi square divided by k so x^ 2/k

-if k is large, reduced chi square is ~ 1

7
New cards

What questions can we answer with chi-square?

  • Given a particular theory, what is the probability that data this different or more different could have occurred?

  • Are the data inconsistent with the model?


8
New cards

How do you calculate the probability of multiple observations?

multiply the individual probabilities together to get the collective probability of all values

9
New cards

How do we minimize the chi-square value?

find parameters a, b that best minimize the value, (can use partial derivatives)

10
New cards

Things that can go wrong with curve fitting

  • Using an incorrect model to represent the data

  • Making a poor choice of starting parameters (too far from correct values; sometimes starting at 0.0 is hard for a program, too)

  • Sometimes parameters land on unphysical values during the chi-square minimization process (1/0, log(-10), sqrt of a negative, etc)

  • Fitting too many parameters at once while far from the minimum chi-square value

  • Choosing a poor set of model parameters (high correlation, large difference in scale)


11
New cards

too many pararmeters for a model means…

means your model can describe anything & is sensitive to fluctuations (John Von Neumann: "with four parameters I can fit an elephant, with five I can make him wiggle his trunk")

12
New cards

curve fitting with scipy: what is the name of the function and what parameters do you enter?

To perform a curve fit on histogram data in SciPy, you need to use the scipy.optimize.curve_fit function and explicitly provide the bin centers as the x data. • The y data will be the histogram's bin heights.

13
New cards

How to check if you have a probability distribution (density=true)?

If you integrate the distribution, the value should be ~1.

14
New cards

If you perform a curve fit on a dataset containing k data points using a model with n_params adjustable parameters, how is the number of degrees of freedom for assessing fit quality (k_fit) correctly calculated?

K_fit = k - n_params

15
New cards

As a general rule of thumb in data analysis, what does a reduced chi-squared value chi_red^2 = chi^2/k of approximately 1.0 signify?

good agreement between the model and its data; when it is ~1, it means that each data point deviates from the model by one standard deviation on average

16
New cards

When performing a curve fit on histogram data in Python using scipy.optimize.curve_fit, what values should be passed as the independent variable (x data) argument?

the bin centers calculated from the bin edges

17
New cards

What do too large and too small chi2 values imply?

Too LARGE reduced chi2 implies poor agreement btwn theory and data. Too SMALL reduced chi2 (<1) implies one could be OVERFITTING the data – the agreement should still be impacted by the uncertainty on each point.

18
New cards

How can you gauge the quality of your fiit?

By looking at the ā€œfit residuals.ā€ These are the deviation of your data points from the values predicted by your model.

Fit residuals can be measured in terms of standard deviations.


f_r = (data - fit)/sigma

19
New cards

Pull Distribution

The distribution of the fit residuals is called the ā€œpull distribution.ā€

20
New cards

Pull Distribution Properties

If the mean = 0, the model’s shape matches the data well

If the width (sigma) is one, the data points are normally distributed around the model’s predictions, consistent with their uncertainties (sigma)

21
New cards

Cumulative Distribution Function (CDF)

For every probability distribution, there’s an associated ā€œCumulative Distribution Function.ā€ This is the integral from negative infinity to x of the probability function (PDF).

22
New cards

Properties of the CDF

At any point x, the CDF tells us the probability of observing a random number less than or equal to x. As x approaches infinity, the value of the CDF approaches 1.

23
New cards

Batch computing - what is it and why do we use it?

  • Non-interactive computation – prepare a ā€œjobā€ (program) and submit it to run on a remote computer.

  • This can be valuable if your jobs are long, require special computing environments, or you need to run many copies of your code in parallel.


24
New cards

Rivanna

Primairly a batch computing system. Afton+Rivanna = 50,000 cores

25
New cards

Node - what is it and what are the two types?

  • basic building block of a cluster

  • Two types

    • head node - computer used for logging on and submitting jobs

    • computer node - computer that does most of the work


26
New cards

Core

an individual processor on a computer

27
New cards

The main use of the rivanna cluster is in ā€batchā€ mode, what program do we use for this?

A program called SLURM is used to manage jobs:

• Priority

• Input/output data

• Job sections

28
New cards

SLURM

used for submitting jobs to computer nodes from the head node

29
New cards

SLURM script

a SLURM script is a bash script with SLURM directives (#SBATCH) and command-line instructions for running your program

30
New cards

How do you check the status of your jobs? How do you cancel a job?

squeue -u <user id>; scancel <job id #>

31
New cards

SLURM environmental variables

Each job will be provided an environment variable:

  • SLURM_ARRAY_JOB_ID

And each task will be assigned:

  • SLURM_ARRAY_TASK_ID


in a slurm script %A represents the job id and %a represents the task ID


32
New cards

When submitting a SLURM job array on Rivanna, which environment variable is automatically assigned to each task to distinguish its specific index in the array?

  • SLURM_ARRAY_TASK_ID


33
New cards

In the context of Rivanna computing resources, how is 1 Service Unit (SU) defined?

1 core-hour

34
New cards

array syntax for slurm

sbatch --array=1-100 myslurm_array

35
New cards

what’s one way to classify data when you can’t do it by just characteristics?

If we look at the correlations between variables, we can find ways to separate the data based on multi-variable distributions. ie sepal length vs sepal width

36
New cards

Pearson’s correlation coefficient

Pearson’s correlation coefficient provides a numeric FOM for the level of linear correlation

37
New cards

Postive vs Neutral vs Negative Correlation

Positive Correlation: both variables change in the same direction.

Neutral Correlation: No relationship in the change of the variables.

Negative Correlation: variables change in opposite directions.

38
New cards

What crucial component must every recursive function in Python possess to prevent infinite recursion and a runtime error?

a terminating question

39
New cards

Recursive function

Functions that call themselves

40
New cards

Command for creating a pandas dataframe

pd.DataFrame

41
New cards

Empirical Distribution Function

a CDF obtained from the data and not a mathematical model

ECDF(x) = (number of data points <= x)/(total number of data points)

42
New cards

How is an ECDf constructed?

Made form unbinned data; uses raw, measured values

43
New cards

What does the Kolmogorov-Smirnov (KS) test evaluate when comparing a model to a dataset?

The maximum vertical deviation between the empirical cumulative distribution function (ECDF) of the data and the models cumulative distribution function (CDF).

44
New cards

Kolmogorov-Smirnov Statistic D_N

the maximum vertical deviation is called the Kolmogrov-Smirnov statistic