rhayes777 / PyAutoFit

PyAutoFit: Classy Probabilistic Programming
https://pyautofit.readthedocs.io/
MIT License
60 stars 11 forks source link

feature/prior array #1021

Closed rhayes777 closed 3 months ago

rhayes777 commented 4 months ago

Adds the Array class which functions as a PriorModel that creates numpy arrays of floats.

An array is defined by its shape and a prior.

array = af.Array(
    shape=(2, 2),
    prior=af.GaussianPrior(mean=0.0, sigma=1.0),
)

The prior is copied to each index meaning that a 2x2 array has four independent priors.

print(array.prior_count)
> 4

Arrays can be accessed and modified using indexing.

array[0, 0] = 1.0
print(array.prior_count)
> 3

They can be instantiated just as any other model class


instance = array.instance_from_prior_medians()
print(instance)
> [
     [1.0, 0.0],
     [0.0, 0.0],
  ]
rhayes777 commented 4 months ago

Need to check JAX and search chaining. We mostly do config on the type -> prior relationship so it was hard to see how to carry this over

Jammy2211 commented 4 months ago

I would make it so that the config default gives the same prior to everything on the numpy array.

We can worry about JAX and search chaining later on then!

rhayes777 commented 3 months ago

I would make it so that the config default gives the same prior to everything on the numpy array.

We can worry about JAX and search chaining later on then!

So at the moment you define one prior and that gets copied to every slot. Would we want a config to determine the default for all Arrays globally?

rhayes777 commented 3 months ago

Should now work with prior passing and JAX