Skip to content

Instantly share code, notes, and snippets.

View mick001's full-sized avatar

Michy mick001

View GitHub Profile
@mick001
mick001 / normal_data_4.R
Created August 28, 2015 19:42
How to make a rough check to see if your data is normally distributed part 4 (R). Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/07/how-to-make-rough-check-to-see-if-your.html
kurtosis(data_norm)-3
kurtosis(data_beta)-3
# <0 data is platycurtic
# = 0 data is normal
# >0 data is leptocurtic
##########################################################
# Results
# > kurtosis(data_norm)-3
# [1] 0.2875478
@mick001
mick001 / magnetic_field.py
Last active November 1, 2021 06:44
Biot-Savart law: magnetic field of a straight wire, Python simulation. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/05/biot-savart-law-magnetic-field-of.html
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-4,4,10)
y = np.linspace(-4,4,10)
z = np.linspace(-4,4,10)
x,y,z = np.meshgrid(x,y,z)
import matplotlib.pyplot as plt
import numpy as np
import scipy as sc
plt.style.use("dark_background")
fs = 1000
# Time
t = np.linspace(0,1.5-1/fs,1500)
import matplotlib.pyplot as plt
import numpy as np
import scipy as sc
plt.style.use('ggplot')
np.random.seed(20)
#-------------------------------------------------------------------------------
# Set up
@mick001
mick001 / fourier_transform.m
Last active August 29, 2015 09:51
Calculate Fourier transform of a gaussian using Matlab. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/05/calculate-fourier-transform-of-gaussian.html
% Fourier transform calculation
%-------------------------------------------------------
% Declare symbols to use
syms x t;
% Parameters of the transform
a = 300; %scaling
b = 0; %shifting
c = 0; %smoothing
@mick001
mick001 / fourier_B_note.m
Created August 29, 2015 09:54
Applying Fourier to a real signal: guitar musical note B. Full article at http://www.firsttimeprogrammer.blogspot.com/2015/05/applying-fourier-to-real-signal-guitar.html
% Loading wav file
[ip fs] = wavread('B.wav');
% B tone
B = ip;
% Play the recording
sound(B,fs);
% Plot the recording
@mick001
mick001 / spectrogram.m
Created August 29, 2015 09:57
Spectrogram representation of the B note from a guitar. Full article at http://www.firsttimeprogrammer.blogspot.com/2015/05/spectrogram-representation-of-b-note.html
% Loading wav file
[ip, fs] = wavread('B.wav');
% Spectogram
specgram(ip)
import numpy as np
import matplotlib.pyplot as plt
plt.style.use("ggplot")
# Setup
x_ = np.linspace(-20,20,10000)
T = 8
armonics = 10
% Line integral calculation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Variable definition for symbolic calculations
syms t;
% Parametric curve
x = @(t) t;
y = @(t) sqrt(t);
import java.util.Scanner;
import java.util.Random;
public class GuessNumberMain
{
public static void main(String[] args)
{
System.out.println("Guess the number beween 0 and 99");
Scanner reader = new Scanner(System.in);
int number = reader.nextInt();