This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [s] = cubic_spline_interp(X, Y, options) | |
arguments | |
X (1,:) {mustBeVector} | |
Y (1,:) {mustBeVector} | |
options.Plotting (1, 1) string = 'False' | |
end | |
% Calculation of differences between consecutive x-coordinates. | |
n = length(X); | |
h = zeros(n-1, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
__all__ = ["MultinomialNaiveBayes"] | |
class MultinomialNaiveBayes: | |
""" | |
Multinomial Naive Bayes classifier for text data. | |
Parameters: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def miller_test(n: int) -> bool: | |
""" | |
Check if a number is a prime (Miller Test). This algorithm is deterministic. | |
:param n: integer to check | |
:return: True if n is a prime, False otherwise | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function output = decimal_to_IEEE754(decimal) | |
% Given a decimal number, this function returns the exact same number in | |
% IEEE754 format (double precision) | |
% decimal: Decimal number to be converted | |
% output: Converted number (string) | |
% Get the sign bit (0 for positive, 1 for negative) | |
sign = 0; | |
if decimal < 0 | |
sign = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function p = newton_interpolation(x, y) | |
% Plots the Newton Interpolation Polynomial and the divided difference table. | |
% x - the x-coordinates of the data points | |
% y - the y-coordinates of the data points | |
% Number of data points | |
n = length(x); | |
% Divided difference table | |
F = divided_differences(x, y); |