mardi 28 janvier 2020

How to randomly choose coefficients of a linear combination in Python? [closed]

I have a linear combination like

formula

I want to randomly select the coefficients c_i with the constraint

formula

As a minimal example in Python:

import numpy as np

x = 0.1
func_list = [np.sin(x), np.cos(x), x**2]

def linear_comb(a, b, c):
    return a*func_list[0] + b*func_list[1] + c*func_list[2]

How should I sample a , b and c from uniform distributions with the constraint a^2+b^2+c^2=1?




Aucun commentaire:

Enregistrer un commentaire